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

Add a shortlinks Django app. #2167

Merged
merged 2 commits into from
Aug 9, 2021
Merged

Add a shortlinks Django app. #2167

merged 2 commits into from
Aug 9, 2021

Conversation

toolness
Copy link
Collaborator

@toolness toolness commented Jul 21, 2021

During our latest NYCx meeting we discussed the possibility of using a short URL service like bit.ly to provide branded short URLs, to make links to external resources provided on the textbot take up less precious characters.

Unfortunately, using bit.ly to create URLs with custom domains isn't very cheap (about $40 per month) and they don't have any kind of nonprofit discount.

As an alternative, I figured it shouldn't be too hard to roll-our-own extremely simplistic short URL service as a feature on the tenant platform. Admins could log into our Django admin backend and use a basic UI to create urls that would be of the form https://app.justfix.nyc/s/<some short id>.

Aside from being useful to shorten URLs though, creating a layer of redirection has some other advantages:

  • We have the ability to update where our short URLs point. This means, for example, if we send a text message that says "go here to learn more about rent reductions" and points to a URL on a government website, it that URL eventually 404's and the user is going through their SMS text history and taps the link, it will 404 too. However, if the link points to a short URL we've provided, and we change the link's target once it 404's, then tapping that link won't 404 anymore.

  • We can change our external URLs in just one place. For instance, if we have a single short URL that points to a government page on obtaining rent reductions, and we link to our short URL in our learning center articles and our tenant platform and our text bot, then if the target of that URL ever changes, we can just update the short URL target, instead of having to manually update the content of all our properties.

  • We could regularly sweep through our short URLs and be alerted of any that 404. To figure out which links have rotted, we can simply iterate through all the short URLs in our database and regularly check which ones 404.

This adds the feature via a new Django app called shortlinks, which Outreach Coordinators have the ability to create and modify.

Limitations

  • This doesn't currently record visits to shortlinks in any way, so we can't easily do metrics (unless we parse our log files, I guess).
  • These links aren't super short, e.g. app.justfix.nyc/s/boop could be further shortened to something like jf.nyc/boop, but that would take more work.
  • There's no version history, so it's not easy to revert a change to a shortlink. We could add django-reversion to get this, though.

@toolness
Copy link
Collaborator Author

[ch7644]

@shortcut-integration
Copy link

@toolness toolness requested a review from samaratrilling July 21, 2021 13:50
@toolness
Copy link
Collaborator Author

toolness commented Aug 9, 2021

Hey @samaratrilling any idea when you might be able to review this? I think Steph might need its functionality soon-ish for the NYCx work, but I don't think there's an urgent rush.

@samaratrilling
Copy link
Contributor

samaratrilling commented Aug 9, 2021 via email

Copy link
Contributor

@samaratrilling samaratrilling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Might be worth setting the max length of the slug to something a little lower than 200 chars, but that's not a big deal.

So outreach coordinators will be able to edit these on the django admin dashboard?

@toolness
Copy link
Collaborator Author

toolness commented Aug 9, 2021

Awesome, thanks! Yeah, 200 characters is a kind of weird max but I prefer to over-estimate unless there are significant drawbacks to not doing so, but we can always make it shorter later if needed too.

Correct, outreach coordinators will be able to add/edit these. Come to think of it, though, the "Tenant Resource Editors" group should also probably have access to add/edit these, since these shortlinks are basically used as tenant resources... hmm. I guess we can always add that permission later, though.

@toolness toolness merged commit 02f2f60 into master Aug 9, 2021
@toolness toolness deleted the shortlinks branch August 9, 2021 15:44
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