Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android notif: Fix bug clearing notifs with colliding message IDs
This bug would be tricky to reproduce, but seems definitely there from studying the code. When we get a RemoveFcmMessage, it lists a number of Zulip message IDs which were read, and for which we should clear notifications in the UI. But a Zulip message ID is unique only on a given server; a message ID like 12345 will identify one message on one server, and some other message on another server. So it's entirely possible (though it'd be a rather unlucky coincidence) for the user to have active notifications at the same time for two conversations on two different Zulip servers that happen to include messages with the same Zulip message ID, and even for their respective latest messages to have the same message ID. In that case, when the user goes and reads one of those conversations on one server so that we get a RemoveFcmMessage for that message, the existing (recently-added) code here would clear both conversations' notifications. The bug could also trigger just as well if the notification for the just-read message was already cleared -- for example, if the user opened that notification and that's what led to reading the message. In that case, we'd clear just one notification, but it'd be a wrong one that shouldn't be cleared. To fix the bug, we just need to limit this loop to operate on notifications that are for the right Zulip identity. (Limiting to the right Zulip server would be enough to fix this bug; but limiting to the right identity is both easier and cleaner, as the whole RemoveFcmMessage is addressed to a particular Zulip identity.)
- Loading branch information