Skip to content

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Nov 26, 2025

It doesn't make sense that homeserver is emitting the events homeserver.matrix.presence and homeserver.matrix.typing if the configuration says to not process them.

Summary by CodeRabbit

  • Chores
    • Typing and presence detection can now be independently configured and disabled through system configuration settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Walkthrough

The pull request adds config-driven guards to the event service's typing and presence processing methods. Both processTypingEDU and processPresenceEDU now fetch configuration via configService.getConfig('edu') and return early if the corresponding config flags are disabled, allowing conditional processing based on configuration.

Changes

Cohort / File(s) Summary
Config-driven guards in event processing
packages/federation-sdk/src/services/event.service.ts
Added early-return guards in processTypingEDU and processPresenceEDU methods to respect edu.processTyping and edu.processPresence config flags respectively

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with consistent, repetitive pattern applied to two methods
  • Guard logic is straightforward and follows standard early-return patterns
  • No structural changes or complex logic to evaluate

Possibly related PRs

  • RocketChat/homeserver#293: Introduced the edu.processTyping and edu.processPresence config entries that are now being consumed by these guard clauses

Suggested reviewers

  • ggazzo

Poem

🐰 Config guards stand tall and true,
Processing typing, presence too!
Early returns when flags say "no,"
Let the federation flow!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing edu events from being emitted when not configured to process them, which directly addresses the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dont-emit-edu-based-on-config

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.84%. Comparing base (ce93256) to head (be6632c).

Files with missing lines Patch % Lines
...kages/federation-sdk/src/services/event.service.ts 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #310      +/-   ##
==========================================
- Coverage   53.15%   52.84%   -0.31%     
==========================================
  Files          96       96              
  Lines       12573    12583      +10     
==========================================
- Hits         6683     6650      -33     
- Misses       5890     5933      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/federation-sdk/src/services/event.service.ts (1)

321-324: LGTM! Consider defensive coding and observability improvements.

The config-driven guard correctly prevents typing event emission when disabled. The early return is safe since no processing has occurred yet.

Consider these optional improvements:

  1. Defensive config access to prevent runtime errors if the config structure is unexpected:
 const config = this.configService.getConfig('edu');
-if (!config.processTyping) {
+if (!config?.processTyping) {
   return;
 }
  1. Add debug logging for observability when skipping processing:
 const config = this.configService.getConfig('edu');
 if (!config?.processTyping) {
+  this.logger.debug('Skipping typing EDU processing (disabled in config)');
   return;
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ce93256 and be6632c.

📒 Files selected for processing (1)
  • packages/federation-sdk/src/services/event.service.ts (2 hunks)
🔇 Additional comments (1)
packages/federation-sdk/src/services/event.service.ts (1)

351-354: Rewritten review comment: The config-driven guard correctly prevents presence event emission when disabled. The early return safely prevents all processing.

The EDU config structure in packages/federation-sdk/src/services/config.service.ts defines processTyping and processPresence as required boolean properties (lines 34-37, validated by Zod schema at 75-78). Since getConfig('edu') returns AppConfig['edu'] with these properties guaranteed to exist, optional chaining (?.) is unnecessary and the current direct property access is correct.

The pattern matches processTypingEDU (line 321), which also uses direct access without optional chaining.

Optional improvement: Consider adding debug logging for observability:

 const config = this.configService.getConfig('edu');
 if (!config.processPresence) {
+  this.logger.debug('Skipping presence EDU processing (disabled in config)');
   return;
 }

@ggazzo ggazzo merged commit 2833339 into main Nov 26, 2025
3 checks passed
@ggazzo ggazzo deleted the dont-emit-edu-based-on-config branch November 26, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants