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
Added link shortener #1372
Added link shortener #1372
Conversation
@mtrojan-ub, this looks like an excellent start! I'll try to test in the near future (after finishing up #1354). From a first glance, I have a few minor questions: 1.) Do you want any help cleaning up the style issues that are causing Travis to complain? I'm happy to help if necessary. 2.) Do you think there is any value in adding a key field of some sort to the database field, to make it harder to reverse engineer the base62 and examine arbitrary links? That is, have a row besides the id that just contains a random integer, and then generate the link with two base62-encoded values -- one for the id and one for the key. I'm not sure whether privacy concerns are strong enough to justify this, but it wouldn't make the link too much longer and would cover more bases. 3.) If we eventually add handlers to use external link shortener services via API, we will need to work with full URLs, not just paths. Do you think it might make sense to deal in full URLs everywhere for consistency, or should we add the logic to convert paths to full URLs inside future API-based plugins as needed? 4.) Did you look into the possibility of shortening links in the SMS logic as well? (I can work on that if you like -- just trying to think if there are more places where this might be useful). |
@demiankatz: Thanks for having a look!
But since the decision whether the full URL or only parts of it is encapsulated via the UrlShortenerInterface, additional plugins are able to store the full URL if needed, so that should not be a problem (so i guess it would be better to implement it in other plugins "as needed").
|
Thanks, @mtrojan-ub, your reasoning on item 3 (not storing full URLs at this time) makes sense to me. I'll look into fixing the style issue and adding SMS support when time permits in the next week or two. Regarding "more secure shortlinks," I don't have a really strong feeling about this, except that it might be easier to introduce the security now rather than adding it later if we decide it's needed. I'll investigate whether there's a very simple solution that might work. Finally, it might make sense to build a command line tool for manually creating short links if that's going to be a need on your end. Let me know if you'd like help setting that up. |
@mtrojan-ub, I've had some time to work on this further. A few notes: 1.) I decided not to add the "more secure linking" functionality we discussed; as you say, it may not matter, and if it turns out to be needed, we can always build a DatabaseWithObfuscation service or something at a future date. For now, keeping this as simple as possible seems worthwhile. 2.) Another thought that occurred to me was adding logic to search for existing paths in the database to avoid creation of duplicate rows... but performance concerns (searches will get slower and slower as the table grows) persuaded me not to do that. But it might make sense as a config option in future. 3.) I fixed a handful of bugs and added some test coverage. 4.) I ended up moving the link shortening logic out of the Mailer object and into a view helper. This was necessary to support short links in SMS, and it also makes it easier to introduce short links to other custom mail templates in the future. 5.) It would definitely still be valuable to have some command line utilities for creating short links and cleaning old entries out of the table. If you have time to build those, please share in the future... but for now, I think that the work here is complete enough to merge, so I will do that shortly. |
Thanks @demiankatz! Sorry for the late response, but i've been on vacation. I'm not sure if we will create command line utilities for this purpose, but if so, we will be glad to share them. |
Here's the first implementation, details can be found here:
https://sourceforge.net/p/vufind/mailman/message/36665613/
A few hints:
DB:
As always, i'll be glad for any feedback!
TODO