Skip to content

notif: Ignore notifications for logged out accounts #1349

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

Merged
merged 3 commits into from
Apr 15, 2025

Conversation

tomlin7
Copy link
Contributor

@tomlin7 tomlin7 commented Feb 12, 2025

Fixes: #1264

Changes

  • Ignores notifications received for accounts that were logged out while the app was offline
  • Removes notifications (if there exist) of the user when the user logs out

@gnprice
Copy link
Member

gnprice commented Feb 12, 2025

Thanks @tomlin7 for the contribution! Before we can review this, it will need a test — see the repo's README file.

@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Feb 14, 2025
@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 4 times, most recently from 6c31bb2 to 51c72de Compare February 15, 2025 20:27
Copy link
Collaborator

@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.

Thanks! Comments below from a brief review.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 3 times, most recently from 90daa5f to bbd7f14 Compare February 21, 2025 20:01
@chrisbobbe chrisbobbe self-assigned this Feb 21, 2025
@chrisbobbe
Copy link
Collaborator

I believe the two questions above that were open now have answers:

So you should be able to proceed, incorporating those.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 2 times, most recently from 610d6d7 to 004951d Compare February 25, 2025 19:57
@tomlin7
Copy link
Contributor Author

tomlin7 commented Feb 25, 2025

@chrisbobbe I have made the requested changes, please review again!

@chrisbobbe
Copy link
Collaborator

Quoting my comment #1349 (comment):

Following that discussion, yeah, we will need to put the new call inside an Android platform conditional.

You haven't done this in this revision; please do that. In logOutAccount, we should only call NotificationDisplayManager .removeNotificationsForAccount if the platform is Android.

Then as an optional, independent improvement, you could add a commit that does this:

Could be helpful to put asserts at the top of [NotificationDisplayManager's] public methods, checking the target platform is indeed Android — because that's basically an assumption the implementation is making

I see some added asserts, but this needs to be done in a separate commit. The current revision only has one commit.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 2 times, most recently from aba2741 to 1405cc1 Compare March 5, 2025 14:28
@tomlin7
Copy link
Contributor Author

tomlin7 commented Mar 5, 2025

@chrisbobbe I have implemented all the requested changes. Let me know if there are any further improvements needed.

Copy link
Collaborator

@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.

Thanks! Comments below.

Also, have you tested this with an Android device or emulator?

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 6 times, most recently from b49b478 to b88bb4d Compare March 16, 2025 00:17
@tomlin7
Copy link
Contributor Author

tomlin7 commented Mar 16, 2025

@chrisbobbe I have tested this with an Android device (both debug and release).

Copy link
Collaborator

@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.

Thanks! A few comments from a brief review—also, some tests are failing; please fix those.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 2 times, most recently from 27bcdc2 to f6bc3b6 Compare March 22, 2025 10:12
@gnprice
Copy link
Member

gnprice commented Mar 25, 2025

@rajveermalviya, would you take a look at this and

  • check for any interactions with your upcoming notif ios: Handle opening of conversation on tap; take 2 #1379 which might mean something should be done differently here (as well as any other points that jump out at you);
  • do a round of manual testing to confirm this behaves correctly? (I think the implementation is already very close to what we'll merge; the more substantive comments above are on the tests.)

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Mar 25, 2025
Copy link
Member

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

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

I tested the following cases and verified they work correctly:

  • The notifications being removed when logging-out of the account.
  • Receiving a notification from FCM but not displaying it when the account wasn't found in GlobalStore (simulating that the API call to unregisterToken failed, by commenting it out).

Also since this PR removes the notification by matching groupKey, it should also include the group summary notification and remove it, avoiding a lingering summary notification.

As for the interaction with #1379, apart from little conflicts, there shouldn't be anything that requires changing here, as this PR only checks for the notification group key (to find and remove notifications of the specific account) and there's no change in regarding to that in #1379. And for iOS this shouldn't matter for now (but remains unresolved), as we don't have a way to control displaying notifications there yet (#1265), and also because #1264 is only about Android.

@gnprice
Copy link
Member

gnprice commented Mar 25, 2025

Thanks @rajveermalviya! Sounds good.

@gnprice gnprice removed the maintainer review PR ready for review by Zulip maintainers label Mar 25, 2025
@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 5 times, most recently from e2cf339 to 4dafcb9 Compare March 31, 2025 12:23
@tomlin7 tomlin7 requested a review from gnprice March 31, 2025 12:26
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! These tests look complete now. Comments below.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch 2 times, most recently from 1d43bd8 to ad49b0b Compare April 9, 2025 19:43
@tomlin7 tomlin7 requested a review from gnprice April 9, 2025 19:44
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! This is very close now. Comments below.

Some of these comments are additional cases of things that I mentioned in the previous review. When you get code-review feedback on a PR, one key thing you can do to help keep the PR moving swiftly along to merge is to look for other places where the same comments would apply, and act on the feedback in those places too.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch from ad49b0b to 5f52b54 Compare April 12, 2025 05:20
@tomlin7
Copy link
Contributor Author

tomlin7 commented Apr 12, 2025

Thanks for the suggestions! It's improving my code quality significiantly. I made sure to run the suggestions through all changes made.

@tomlin7 tomlin7 requested a review from gnprice April 12, 2025 05:22
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! Just a few nits remain.

@tomlin7 tomlin7 force-pushed the ignore-notification-removed-account branch from 5f52b54 to 2b0f248 Compare April 15, 2025 19:21
@tomlin7 tomlin7 requested a review from gnprice April 15, 2025 19:22
tomlin7 added 3 commits April 15, 2025 13:59
The `_groupKey` method currently takes an `FcmMessageWithIdentity`
object as an argument. However, this method only requires the
realm URL and user ID from that object. This change modifies the
method signature to directly accept `realmUrl` and `userId` as
arguments.

This change is made to facilitate calling `_groupKey` from
contexts where an `FcmMessageWithIdentity` object is not
available.

Discussion:
  https://chat.zulip.org/#narrow/channel/516-mobile-dev-help/topic/Removing.20notifications.20for.20logged.20out.20account/near/2088813
Fixes: zulip#1264

Notifications are ignored for accounts which were logged out but the
request to stop receiving notifications failed due to some reason.

Also when an account is logged out, any existing notifications for that
account is removed from the UI.
…ethods

NotificationDisplayManager's public methods only get invoked on
Android, and their implementations basically assume the platform is
Android. So, add these asserts, to make that assumption clearer and
to fail early if we accidentally call one of these on iOS.

When we eventually take more hands-on control of notifications on
iOS, we might either adapt this class to support iOS too, or make a
new class for iOS and make this one's name and interface clearer
that it's Android-only.

Discussion:
  https://chat.zulip.org/#narrow/channel/243-mobile-team/topic/NotificationDisplayManager.20Android-only/near/2099196
@gnprice gnprice force-pushed the ignore-notification-removed-account branch from 2b0f248 to 3785963 Compare April 15, 2025 21:20
@gnprice gnprice merged commit 3785963 into zulip:main Apr 15, 2025
@gnprice
Copy link
Member

gnprice commented Apr 15, 2025

All looks good — merging! Thanks again @tomlin7 for all your work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't show notifications for logged-out accounts, on Android
5 participants