Skip to content

hotfix: Set not event-email when search email as default#4451

Open
dab246 wants to merge 3 commits intomasterfrom
hotfix/filter-event-in-mail-search
Open

hotfix: Set not event-email when search email as default#4451
dab246 wants to merge 3 commits intomasterfrom
hotfix/filter-event-in-mail-search

Conversation

@dab246
Copy link
Copy Markdown
Member

@dab246 dab246 commented Apr 14, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Email search filters now exclude Events mail by default unless explicitly included.
  • Tests

    • Updated search filter tests to reflect the new default exclusion and verify combinations with text, multiple recipients, negations, and explicit inclusion of Events.
    • Adjusted tests expecting a combined (AND) filter structure for time-based and compound queries.

Signed-off-by: dab246 <tdvu@linagora.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aca08728-bbe7-4ea0-9d57-0dcba50dd660

📥 Commits

Reviewing files that changed from the base of the PR and between d2af657 and 9cd5bec.

📒 Files selected for processing (2)
  • test/features/search/search_email_filter_test.dart
  • test/features/search/verify_before_time_in_search_email_filter_test.dart

Walkthrough

Added an import for keyword_identifier_extension.dart and changed mappingToEmailFilterCondition() to always append EmailFilterCondition(notKeyword: KeyWordIdentifierExtension.eventsMail.value) when the incoming hasKeyword list does not contain that events keyword. Tests were updated to expect the events-exclusion condition in composed LogicFilterOperator(AND) results and to verify that the exclusion is omitted when hasKeyword explicitly includes the events keyword.

Possibly related PRs

Suggested labels

search

Suggested reviewers

  • hoangdat
  • tddang-linagora
🚥 Pre-merge checks | ✅ 3
✅ 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 accurately describes the main change: adding a default filter to exclude event emails from email searches, which aligns with the core modifications across the filter logic and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/filter-event-in-mail-search

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.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
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: 1

🧹 Nitpick comments (1)
lib/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart (1)

161-164: Consider guarding explicit Events inclusion beyond hasKeyword.

Right now, only hasKeyword disables the default notKeyword(events) clause. If Events can be selected via another path (e.g., label.keyword), this can create contradictory filters. Consider centralizing an isEventsExplicitlyIncluded check.

♻️ Suggested hardening
+    final isEventsExplicitlyIncluded =
+      hasKeyword.contains(KeyWordIdentifierExtension.eventsMail.value) ||
+      label?.keyword?.value == KeyWordIdentifierExtension.eventsMail.value;
+
     final listEmailCondition = {
       if (emailEmailFilterConditionShared.hasCondition)
         emailEmailFilterConditionShared,
@@
-      if (!hasKeyword.contains(KeyWordIdentifierExtension.eventsMail.value))
+      if (!isEventsExplicitlyIncluded)
         EmailFilterCondition(
           notKeyword: KeyWordIdentifierExtension.eventsMail.value,
         ),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@lib/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart`
around lines 161 - 164, The code currently only checks hasKeyword before adding
an EmailFilterCondition(notKeyword:
KeyWordIdentifierExtension.eventsMail.value), which can conflict if Events are
included via another path (e.g., label.keyword); add a centralized boolean
(e.g., isEventsExplicitlyIncluded) that returns true when hasKeyword OR any
other explicit include (like label?.keyword ==
KeyWordIdentifierExtension.eventsMail.value or other selection flags) and then
replace the hasKeyword check with !isEventsExplicitlyIncluded before emitting
EmailFilterCondition(notKeyword: KeyWordIdentifierExtension.eventsMail.value);
update the logic where EmailFilterCondition is created so all places consult
isEventsExplicitlyIncluded to avoid contradictory filters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@lib/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart`:
- Around line 161-164: Update the tests to reflect that
mappingToEmailFilterCondition() now returns a non-null EmailFilterCondition for
the initial filter because Events (KeyWordIdentifierExtension.eventsMail) is
excluded by default; specifically modify the assertions in
test/features/search/search_email_filter_test.dart starting around line 81 to
expect a non-null EmailFilterCondition with notKeyword ==
KeyWordIdentifierExtension.eventsMail.value, and add a new test case that
verifies an explicit “include Events” scenario (i.e., when hasKeyword includes
KeyWordIdentifierExtension.eventsMail.value the mapping returns null or an
EmailFilterCondition without notKeyword as appropriate).

---

Nitpick comments:
In
`@lib/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart`:
- Around line 161-164: The code currently only checks hasKeyword before adding
an EmailFilterCondition(notKeyword:
KeyWordIdentifierExtension.eventsMail.value), which can conflict if Events are
included via another path (e.g., label.keyword); add a centralized boolean
(e.g., isEventsExplicitlyIncluded) that returns true when hasKeyword OR any
other explicit include (like label?.keyword ==
KeyWordIdentifierExtension.eventsMail.value or other selection flags) and then
replace the hasKeyword check with !isEventsExplicitlyIncluded before emitting
EmailFilterCondition(notKeyword: KeyWordIdentifierExtension.eventsMail.value);
update the logic where EmailFilterCondition is created so all places consult
isEventsExplicitlyIncluded to avoid contradictory filters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e61aa082-96e8-4da3-a030-22c8a4bfe505

📥 Commits

Reviewing files that changed from the base of the PR and between 1d59480 and 52cd120.

📒 Files selected for processing (1)
  • lib/features/mailbox_dashboard/presentation/model/search/search_email_filter.dart

Signed-off-by: dab246 <tdvu@linagora.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
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: 1

🧹 Nitpick comments (1)
test/features/search/search_email_filter_test.dart (1)

121-135: Assert the events exclusion explicitly here.

Line 135 only checks the condition count, so this can still pass if the third condition is unrelated. Since this hotfix is specifically about the default events exclusion, assert that one EmailFilterCondition has notKeyword == KeyWordIdentifierExtension.eventsMail.value, not just that there are three entries.

Suggested test hardening
         expect(result, isA<LogicFilterOperator>());
         final logicOperator = result as LogicFilterOperator;
         expect(logicOperator.operator, Operator.AND);
         expect(logicOperator.conditions.length, equals(3));
+        expect(
+          logicOperator.conditions.whereType<EmailFilterCondition>().any(
+            (condition) =>
+                condition.notKeyword ==
+                KeyWordIdentifierExtension.eventsMail.value,
+          ),
+          isTrue,
+        );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/features/search/search_email_filter_test.dart` around lines 121 - 135,
The test for SearchEmailFilter.mappingToEmailFilterCondition currently only
checks there are three conditions but doesn't verify the default events
exclusion; update the test to explicitly assert that among the
LogicFilterOperator.conditions (from mappingToEmailFilterCondition) there exists
an EmailFilterCondition whose notKeyword equals
KeyWordIdentifierExtension.eventsMail.value, while keeping the existing checks
for operator AND and total length; refer to
SearchEmailFilter.mappingToEmailFilterCondition, LogicFilterOperator,
EmailFilterCondition, and the
notKeyword/KeyWordIdentifierExtension.eventsMail.value identifiers to locate and
add the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/features/search/search_email_filter_test.dart`:
- Around line 246-260: Add two additional test cases around
SearchEmailFilter.mappingToEmailFilterCondition to catch membership bugs: (1)
when hasKeyword contains a non-events keyword (ensure
EmailFilterCondition.notKeyword is the events exclusion and hasKeyword reflects
only the provided non-events value), and (2) when hasKeyword contains eventsMail
plus another keyword (ensure eventsMail presence prevents setting notKeyword
while hasKeyword includes both values). Use
KeyWordIdentifierExtension.eventsMail.value and other keyword identifiers, and
assert EmailFilterCondition.hasKeyword and EmailFilterCondition.notKeyword
accordingly to validate membership rather than exact-set equality.

---

Nitpick comments:
In `@test/features/search/search_email_filter_test.dart`:
- Around line 121-135: The test for
SearchEmailFilter.mappingToEmailFilterCondition currently only checks there are
three conditions but doesn't verify the default events exclusion; update the
test to explicitly assert that among the LogicFilterOperator.conditions (from
mappingToEmailFilterCondition) there exists an EmailFilterCondition whose
notKeyword equals KeyWordIdentifierExtension.eventsMail.value, while keeping the
existing checks for operator AND and total length; refer to
SearchEmailFilter.mappingToEmailFilterCondition, LogicFilterOperator,
EmailFilterCondition, and the
notKeyword/KeyWordIdentifierExtension.eventsMail.value identifiers to locate and
add the assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf4925bc-fa87-4cb3-8559-09ecbed4620e

📥 Commits

Reviewing files that changed from the base of the PR and between 52cd120 and d2af657.

📒 Files selected for processing (1)
  • test/features/search/search_email_filter_test.dart

Comment thread test/features/search/search_email_filter_test.dart Outdated
@github-actions
Copy link
Copy Markdown

This PR has been deployed to https://linagora.github.io/tmail-flutter/4451.

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@chibenwa
Copy link
Copy Markdown
Member

chibenwa commented Apr 14, 2026

Well I STRONGLY disagree with that change.

I do believe that pleople are actually interested in email about event and might actually actively look for them.

I thus challenge this functionnal requirement that I believe is misplaced.

What are other email providers doing? Is GMail for instance actively filtering out events from my email search ?

Cc @poupotte

Copy link
Copy Markdown
Member

@chibenwa chibenwa left a comment

Choose a reason for hiding this comment

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

Cf earlier comment

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.

3 participants