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

Fix notification counts for encrypted rooms with ignored event rules #3130

Merged
merged 13 commits into from
Feb 15, 2023

Conversation

Half-Shot
Copy link
Contributor

@Half-Shot Half-Shot commented Feb 6, 2023

Fixes element-hq/element-web#24448

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • [N/A] Sign-off given on the changes (see CONTRIBUTING.md)

Notes: Fix a bug where events in encrypted rooms would sometimes erroneously increment the total unread counter after being processed locally.

This PR aims to fix the problem where currently events with pushrules calculated clientside that emit a {notify: false} are still calculated as increasing the unread counter in a room. This refactors one of the critical functions for dealing with it, so please review with care.

In terms of the changes here, we:

  • Stop relying on the Total notification count entirely for encrypted rooms because unlike with the highlight count where the client generally has a higher count than the server, the total count is most likely to be lower in reality. Therefore, we ignore the server and calculate our own every time.
  • There are now a lot of comments rationalising the various if blocks.
  • I've slightly adjusted some of the ordering in the fixNotificationCountOnDecryption function to avoid doing so many non-null assertions.

Here's what your changelog entry will look like:

🐛 Bug Fixes

@Half-Shot Half-Shot requested a review from a team as a code owner February 6, 2023 17:11
@Half-Shot Half-Shot changed the title Hs/fix notif counts Fix notification counts for encrypted rooms with ignored event rules Feb 6, 2023
@Half-Shot Half-Shot requested review from germain-gg and removed request for weeman1337 and alunturner February 6, 2023 17:12
@Half-Shot Half-Shot marked this pull request as ready for review February 7, 2023 10:10
Copy link
Contributor

@germain-gg germain-gg left a comment

Choose a reason for hiding this comment

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

Otherwise looks sensible!
Sorry that took a little while for me to review

return;
}

if (oldHighlight !== newHighlight || currentHighlightCount > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it also check for actions.notify or does it affect, total and total only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is handled by the if statement below. This just checks the highlights specifically.

@Half-Shot Half-Shot merged commit 195d173 into develop Feb 15, 2023
@Half-Shot Half-Shot deleted the hs/fix-notif-counts branch February 15, 2023 11:25
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Mar 15, 2023
* Add easy way to determine if the decryption failure is due to "DecryptionError: The sender has disabled encrypting to unverified devices." ([\matrix-org#3167](matrix-org#3167)). Contributed by @florianduros.
* Polls: expose end event id on poll model ([\matrix-org#3160](matrix-org#3160)). Contributed by @kerryarchibald.
* Polls: count undecryptable poll relations ([\matrix-org#3163](matrix-org#3163)). Contributed by @kerryarchibald.
* Fix spec compliance issue around encrypted `m.relates_to` ([\matrix-org#3178](matrix-org#3178)).
* Fix reactions in threads sometimes causing stuck notifications ([\matrix-org#3146](matrix-org#3146)). Fixes element-hq/element-web#24000. Contributed by @justjanne.
* Better type guard parseTopicContent ([\matrix-org#3165](matrix-org#3165)). Fixes matrix-org/element-web-rageshakes#20177 and matrix-org/element-web-rageshakes#20178.
* Fix a bug where events in encrypted rooms would sometimes erroneously increment the total unread counter after being processed locally. ([\matrix-org#3130](matrix-org#3130)). Fixes element-hq/element-web#24448. Contributed by @Half-Shot.
* Stop the ICE disconnected timer on call terminate ([\matrix-org#3147](matrix-org#3147)).
* Clear notifications when we can infer read status from receipts ([\matrix-org#3139](matrix-org#3139)). Fixes element-hq/element-web#23991.
* Messages sent out of order after one message fails ([\matrix-org#3131](matrix-org#3131)). Fixes element-hq/element-web#22885 and element-hq/element-web#18942. Contributed by @justjanne.
@t3chguy
Copy link
Member

t3chguy commented Jul 31, 2023

Context https://gist.github.com/Half-Shot/f9501916363894761a1659250aa25181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SuppressNotice push rule does not prevent the total notification count from increasing in encrypted rooms
3 participants