Skip to content

fix: Notifications for thread messages are sent even after thread has been read - #31181

Merged
kodiakhq[bot] merged 9 commits into
developfrom
fix/clear-notifications-thread
Dec 13, 2023
Merged

fix: Notifications for thread messages are sent even after thread has been read#31181
kodiakhq[bot] merged 9 commits into
developfrom
fix/clear-notifications-thread

Conversation

@matheusbsilva137

@matheusbsilva137 matheusbsilva137 commented Dec 7, 2023

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

  • Clear notification queue after they thread messages have been read by a user;

Issue(s)

Steps to test or reproduce

Start a thread with two or more users, and keep it open for both of them while no new message is sent in the main room.
Send a thread message with user A, then read it with user B (by keeping the thread open or opening the thread after the message is sent).
Current behavior: a push notification is sent after some minutes;
Expected behavior: no push notifications should be sent since the messages have been read (the queue can be checked in the rocketchat_notification_queue db collection). Notifications should be cleared when using getThreadMessages or readThreads methods.

Further comments

SUP-386

@codecov

codecov Bot commented Dec 7, 2023

Copy link
Copy Markdown

Codecov Report

Merging #31181 (a5f7273) into develop (1bcb57c) will decrease coverage by 28.51%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop   #31181       +/-   ##
============================================
- Coverage    77.38%   48.87%   -28.51%     
============================================
  Files          276     3270     +2994     
  Lines         8715    80304    +71589     
  Branches      1607    16378    +14771     
============================================
+ Hits          6744    39248    +32504     
- Misses        1565    36405    +34840     
- Partials       406     4651     +4245     
Flag Coverage Δ
e2e 51.32% <ø> (∅)
e2e-api 40.67% <ø> (?)
unit 77.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@changeset-bot

changeset-bot Bot commented Dec 7, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a5f7273

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/omnichannel-services Patch
rocketchat-services Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/presence Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/api-client Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/web-ui-registration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matheusbsilva137
matheusbsilva137 marked this pull request as ready for review December 7, 2023 15:37
@matheusbsilva137
matheusbsilva137 requested review from a team as code owners December 7, 2023 15:37
heitortanoue
heitortanoue previously approved these changes Dec 8, 2023

@sampaiodiego sampaiodiego left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the actual solution should be calling await NotificationQueue.clearQueueByUserId(uid); from readThread function:

export const readThread = async ({ userId, rid, tmid }: { userId?: string; rid: string; tmid: string }) => {

the way it works we just clear the whole queue if the user is active in the system.. we don't actually care of what is in the queue

@matheusbsilva137

Copy link
Copy Markdown
Contributor Author

I think the actual solution should be calling await NotificationQueue.clearQueueByUserId(uid); from readThread function

Ohhh agreed 🤔 that's by the definition of how our notifications should work 😬 not checking "scope"
Thanks!

@sampaiodiego

Copy link
Copy Markdown
Member

I think the actual solution should be calling await NotificationQueue.clearQueueByUserId(uid); from readThread function

Ohhh agreed 🤔 that's by the definition of how our notifications should work 😬 not checking "scope" Thanks!

yes, exactly.. if the user has made any action within the application we just wipe out the notification queue..

the idea is that since the user is active using the application we don't need to bother him by sending push or email notifications.

@MarcosSpessatto MarcosSpessatto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we must do the same here, don't we? https://github.com/RocketChat/Rocket.Chat/blob/develop/apps/meteor/ee/server/local-services/message-reads/service.ts#L11

Ideally we should unify everything in a single place, but we can do that in another PR.

@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 13, 2023
@dionisio-bot dionisio-bot Bot added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels Dec 13, 2023
@matheusbsilva137
matheusbsilva137 dismissed MarcosSpessatto’s stale review December 13, 2023 13:11

As we discussed, this won't be needed since the MessageReads service is only used in the callbacks (after the notification queue has been cleared). Thanks for the review!

@kodiakhq
kodiakhq Bot merged commit fae558b into develop Dec 13, 2023
@kodiakhq
kodiakhq Bot deleted the fix/clear-notifications-thread branch December 13, 2023 13:49
gabriellsh added a commit that referenced this pull request Dec 13, 2023
…/emailEmoji

* 'develop' of github.com:RocketChat/Rocket.Chat:
  chore: `Field` normalization (#31182)
  refactor: `Conversations` Overview Analytics (#31217)
  fix: Notifications for thread messages are sent even after thread has been read (#31181)
  ci: remove carryforward from codecov (#31216)
  fix: Wrong sysmessage when resuming chat from on hold (#31205)
  fix: Gallery not working inside threads (#31213)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants