[TMail] JAMES-4191: KeywordEmailQueryViewListener should clean up sharee's view upon MessageContentDeletionEvent#2282
Conversation
…n the message is no longer referenced by the user Given the `MessageContentDeletionEvent` is emitted easygoing now.
…ree's view upon MessageContentDeletionEvent Team mailbox cases + Keyword view added.
WalkthroughThis pull request updates message deletion and keyword view handling to respect mailbox access rights. The Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tmail-backend/tmail-third-party/ai-bot/src/main/java/com/linagora/tmail/mailet/rag/RagDeletionListener.java (1)
52-52: Consider using a more descriptive system session username.The hardcoded
Username.of("admin")works because mapper operations don't require specific user privileges, but it differs from patterns elsewhere in the codebase wheresessionProvider.createSystemSession(actualUsername)is used (seeCleanupService,RecomputeQuotaTeamMailboxesService).Since the session is created once at construction and reused, this is functionally correct. However, for clarity and consistency, consider using a more descriptive constant like
Username.of("rag-deletion-listener")to indicate this is a technical session for internal operations.🔧 Optional: Use descriptive system session username
- private static final Username ADMIN = Username.of("admin"); + private static final Username SYSTEM_USER = Username.of("rag-deletion-listener");Also applies to: 55-72
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tmail-backend/tmail-third-party/ai-bot/src/main/java/com/linagora/tmail/mailet/rag/RagDeletionListener.java` at line 52, Replace the generic admin username with a descriptive system-session name in RagDeletionListener: change the ADMIN constant (private static final Username ADMIN = Username.of("admin")) to something like Username.of("rag-deletion-listener") and ensure the existing use with sessionProvider.createSystemSession(ADMIN) remains unchanged so the session is still created once in the constructor; update any related references in this class (constructor and methods that reuse ADMIN/session) to use the new constant for clarity and consistency with other services like CleanupService and RecomputeQuotaTeamMailboxesService.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@tmail-backend/tmail-third-party/ai-bot/src/main/java/com/linagora/tmail/mailet/rag/RagDeletionListener.java`:
- Line 52: Replace the generic admin username with a descriptive system-session
name in RagDeletionListener: change the ADMIN constant (private static final
Username ADMIN = Username.of("admin")) to something like
Username.of("rag-deletion-listener") and ensure the existing use with
sessionProvider.createSystemSession(ADMIN) remains unchanged so the session is
still created once in the constructor; update any related references in this
class (constructor and methods that reuse ADMIN/session) to use the new constant
for clarity and consistency with other services like CleanupService and
RecomputeQuotaTeamMailboxesService.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce965901-c76d-427d-8589-93339d403dd4
📒 Files selected for processing (8)
james-projecttmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/event/KeywordEmailQueryViewListener.javatmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/projections/MailboxReadRightsResolver.javatmail-backend/jmap/extensions/src/test/java/com/linagora/tmail/james/jmap/event/KeywordEmailQueryViewListenerTest.javatmail-backend/jmap/extensions/src/test/java/com/linagora/tmail/james/jmap/projections/MailboxReadRightsResolverTest.javatmail-backend/mailbox/plugin/tmail-deleted-message-vault/common/src/main/java/com/linagora/tmail/vault/TeamMailboxDeletedMessageVaultDeletionListener.javatmail-backend/tmail-third-party/ai-bot/src/main/java/com/linagora/tmail/mailet/rag/RagDeletionListener.javatmail-backend/tmail-third-party/ai-bot/src/test/java/com/linagora/tmail/mailet/rag/RagDeletionListenerTest.java
Arsnael
left a comment
There was a problem hiding this comment.
Thanks for completing this :)
chibenwa
left a comment
There was a problem hiding this comment.
Awesome tests!
Really good work.
Thanks a lot for this level of functional coverage on such a sensible fonctional topic.
|
Merging fast for SHA-1 upgrades |
Also,
RagDeletionListenerwas adapted.Summary by CodeRabbit
Bug Fixes
Tests