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

notifications: Match on realm domain, not href. #4817

Merged

Conversation

WesleyAC
Copy link
Contributor

We had a steady stream of errors in Sentry caused by differences between
the known_urls and realm_uri, where one of those had an extra / on
the end (or some more surprising junk, such as a /join/ link). Since
we don't support running Zulip on a non-root path [1], we can simply
compare the domain instead of the href. This is probably more of a
band-aid than a real fix (we should figure out how the strange values
get into known_urls and fix that), but we might as well just check the
domain, since the path doesn't matter.

Related: #4309.

[1] https://chat.zulip.org/#narrow/stream/3-backend/topic/support.20for.20running.20on.20non-webroot.20url.3F

@WesleyAC WesleyAC force-pushed the notifications-match-domain-not-href branch from e2c9921 to ba5bae3 Compare June 21, 2021 23:18
Copy link
Contributor

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Great, thanks! I haven't yet traced through how much of #4309 this will fix, but this seems like an obvious improvement to make. See one small comment below.

@@ -48,7 +48,7 @@ export const getAccountFromNotificationData = (

const urlMatches = [];
identities.forEach((account, i) => {
if (account.realm.href === realmUrl.href) {
if (account.realm.host === realmUrl.host) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually compare .origin, not .host (e.g., as in e47a143). .origin should have everything in .host, plus the scheme, like http or https, which I'd be inclined to differentiate on. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah, I was considering that when I made this, but didn't realize .origin was a thing. I'll change that, since in theory someone could run two different zulip servers, one on http://example.com and the other on https://example.com, even if that would be... extremely chaotic :p

We had a steady stream of errors in Sentry caused by differences between
the `known_urls` and `realm_uri`, where one of those had an extra `/` on
the end (or some more surprising junk, such as a `/join/` link) [1].
Since we don't support running Zulip on a non-root path [2], we can
simply compare the domain instead of the href. This is probably more of
a band-aid than a real fix (we should figure out how the strange values
get into `known_urls` and fix that), but we might as well just check the
domain, since the path doesn't matter.

Related: zulip#4309.

[1] zulip#4309 (comment)
[2] https://chat.zulip.org/#narrow/stream/3-backend/topic/support.20for.20running.20on.20non-webroot.20url.3F
@WesleyAC WesleyAC force-pushed the notifications-match-domain-not-href branch from ba5bae3 to 63cc7fd Compare June 22, 2021 19:53
@WesleyAC
Copy link
Contributor Author

Revision pushed :)

@gnprice
Copy link
Member

gnprice commented Jul 2, 2021

LGTM, thanks! Please merge at will.

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.

3 participants