Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix schema in viber locator hrefs from file-->editor #208

Merged
merged 2 commits into from
Feb 28, 2021

Conversation

ankostis
Copy link
Contributor

In promnesia's search-results tab, links like file:///.ViberPC/123/viber.db do not work,
due to security (i guess, bc these urls work fine when pasted in a new tab).

The custom schema editor: offers a better UX,
since it gives the user the choice of which app to use to open the Viber's db-file (e.g. sqlitebrowser`),
when the mime-type is known to the OS (see the 1st resource, below).

These resources are relevant:

@karlicoss I want your tip about the mime-type handler to be included in the Viber docs; any idea where or how to include it?

..., `file:` does not work in search results
(only if copy-pasted into a new tab).
@ankostis
Copy link
Contributor Author

This PR fixes also a minor bug in the SQL-query, which previously fetched even overwritten due-to-edits viber messages.

@karlicoss
Copy link
Owner

Another way to achieve this is the post-index hook

def HOOK(visit: Res[DbVisit]) -> Iterable[Res[DbVisit]]:
# NOTE: might be a good idea to check that the visit is an exception first and yield it intact?
nurl = visit.norm_url
if 'page1' in nurl:
yield visit._replace(norm_url='patched.com')
elif 'page2' in nurl:
None.boom # deliberately crash
elif 'page3' in nurl:
# just don't yield anything! it will be omitted
pass
elif 'page4' in nurl:
# can emit multiple!
yield visit
yield visit
elif 'page6' in nurl:
# patch locator
yield visit._replace(locator=Loc.make(title='some custom timte', href='/can/replace/original/path'))
else:
yield visit
'''):

So e.g. you could do something like "if source is viber, then replace url etc etc".

But if you think it makes sense as a setting too, happy to merge.
I guess the whole thing with mime type configuration needs a bit more thinking. Maybe in general Promnesia could even offer multiple ways of opening the link (e.g. via sqlitebrowser and via web app (if it's possible, e.g. like for Telegram), etc, etc). Kind of related to #147 (comment)

@ankostis
Copy link
Contributor Author

I think a better idea would be to make the url more configurable, e.g. store a print-pattern in the config,
but i believe we can merge this for the forseable future.

@karlicoss karlicoss merged commit 708d073 into karlicoss:master Feb 28, 2021
@ankostis ankostis deleted the viber-schema branch March 30, 2021 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants