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

refactor: EmailInbox out of DB Watcher #32501

Merged
merged 7 commits into from
May 31, 2024

Conversation

ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented May 25, 2024

As per the updates mentioned in PROJ-7, SCA-11 and ADR #74, this pull request focuses on relocating EmailInbox model out of DB Watcher service.

Context

This modification enhances RocketChat's app by allowing it to directly call listeners through the api.broadcast global function, bypassing the need for MongoDB Change Stream data propagation.

This change offers better control over user notifications via Web Sockets, enabling more precise management of use-cases. Instead of notifying every database change, we can now send an api.broadcast call only when necessary, reducing overall network messages. Additionally, this contributes to the future removal of the DB Watcher deployment, optimizing resource utilization.

Proposed changes

Key changes include:

  • Conditionally incorporating EmailInbox entity import within DB watchers on application startup based on the dbWatchersDisabled flag.
  • Enabling support for the following use cases to directly trigger watch.emailInbox listener event, subject to the dbWatchersDisabled flag.
Updated Use Cases
Use Case Route/Trigger Notes
Insert or update email inbox POST /api/v1/email-inbox
Delete email inbox DELETE /api/v1/email-inbox/:_id
Reconnect to email inbox on IMAPInterceptor IMAPInterceptor reconnect > selfDisable functions

Steps to test or reproduce

  1. Start RocketChat's application with the DISABLE_DB_WATCHERS environment variable set to true.
  2. Perform HTTP requests or simulate use cases listed in the above table.

Further comments

To maintain consistency and avoid potential regressions, event names and signatures have been kept unchanged on both the client and app sides. This decision streamlines efforts and mitigates the risk of unintended consequences.

Additionally, since the EmailInbox model was empty, some new model functions have been created to accommodate specific needs when dealing with database operations.

Copy link
Contributor

dionisio-bot bot commented May 25, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 6.10.0, but it targets 6.9.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented May 25, 2024

⚠️ No Changeset found

Latest commit: 7cb40a2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

codecov bot commented May 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 56.34%. Comparing base (d06df8a) to head (7cb40a2).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #32501      +/-   ##
===========================================
- Coverage    56.34%   56.34%   -0.01%     
===========================================
  Files         2434     2434              
  Lines        53708    53712       +4     
  Branches     11057    11059       +2     
===========================================
+ Hits         30263    30264       +1     
- Misses       20801    20810       +9     
+ Partials      2644     2638       -6     
Flag Coverage Δ
e2e 56.02% <ø> (-0.04%) ⬇️
unit 72.24% <0.00%> (+0.03%) ⬆️

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

@ricardogarim ricardogarim marked this pull request as ready for review May 27, 2024 13:19
@ricardogarim ricardogarim requested review from a team as code owners May 27, 2024 13:19
apps/meteor/server/models/raw/EmailInbox.ts Outdated Show resolved Hide resolved
packages/model-typings/src/models/IEmailInboxModel.ts Outdated Show resolved Hide resolved
apps/meteor/server/models/raw/EmailInbox.ts Outdated Show resolved Hide resolved
apps/meteor/app/api/server/lib/emailInbox.ts Show resolved Hide resolved
@ricardogarim ricardogarim force-pushed the refactor/email-inbox-out-of-db-watcher branch from e1bbd83 to 2733672 Compare May 28, 2024 12:27
@ricardogarim ricardogarim force-pushed the refactor/email-inbox-out-of-db-watcher branch from 2733672 to 935b352 Compare May 28, 2024 12:29
Copy link
Member

@debdutdeb debdutdeb May 28, 2024

Choose a reason for hiding this comment

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

should findoptions be parameters? generally they should, so people can pass especially whatever subset of projections they need, guess the real question is if that should be done in this PR or not. projections here seem to be specific to the usecases in layers above, and later on somebody else might need to touch these files again to add new ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with you, Deb. For this PR, I chose to follow the strict needs of the current use case.

Discussion for the team: should we build methods with "batteries included" from the start, or can we make those changes when they are needed in the future? @sampaiodiego and @MarcosSpessatto, any thoughts?

@sampaiodiego sampaiodiego added the stat: QA assured Means it has been tested and approved by a company insider label May 31, 2024
@sampaiodiego sampaiodiego added this to the 6.10 milestone May 31, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label May 31, 2024
@sampaiodiego sampaiodiego merged commit 3fc12f6 into develop May 31, 2024
50 checks passed
@sampaiodiego sampaiodiego deleted the refactor/email-inbox-out-of-db-watcher branch May 31, 2024 14:13
matheusbsilva137 pushed a commit that referenced this pull request May 31, 2024
Co-authored-by: Diego Sampaio <chinello@gmail.com>
gabriellsh added a commit that referenced this pull request Jun 3, 2024
…retention

* 'develop' of github.com:RocketChat/Rocket.Chat:
  Release 6.9.0
  Release 6.9.0-rc.2
  fix: User status when setting "Use REST instead of websocket for Meteor calls" is disabled (#32500)
  fix: User status when setting "Use REST instead of websocket for Meteor calls" is disabled (#32500)
  regression: Hide prune section based on permission (#32531)
  fix: Users in role table not rendering the empty state properly (#32412)
  refactor: EmailInbox out of DB Watcher (#32501)
  ci: increase issue allowed stale time (#32523)
  regression: Remove impossible sorting from users table "registration status" column (#32506)
  feat: Add contentDisposition option to file storages (#31974)
  i18n: Rocket.Chat language update from LingoHub 🤖 on 2024-05-28Z (#32508)
  Release 6.9.0-rc.1
  fix: Re-login same browser tab issues (#32479)
  regression: Replace read receipt single icon (#32486)
  regression: Incorrect retention policy banner's display rule for teams (#32483)
  chore: Publish npm packages again (#32463)
  ci: publish missing Omnichannel services to DockerHub (#32462)
  Release 6.9.0-rc.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants