Skip to content

fix(notifications): skip disabled email recipients - #3518

Open
michaelstingl wants to merge 4 commits into
opencloud-eu:mainfrom
michaelstingl:fix/skip-disabled-notification-recipients
Open

fix(notifications): skip disabled email recipients#3518
michaelstingl wants to merge 4 commits into
opencloud-eu:mainfrom
michaelstingl:fix/skip-disabled-notification-recipients

Conversation

@michaelstingl

Copy link
Copy Markdown
Contributor

Description

Skip notification emails to users disabled through OpenCloud's user management. This covers share notifications to direct recipients and group members, mentions, and daily or weekly grouped emails, including events stored before disablement.

Related Issue

Related to #3513

Motivation and Context

The check uses GetUserByClaim before sending because GetUser does not exclude disabled LDAP users.

An existing LDAP lookup cache entry can delay suppression until it expires (10 seconds by default). Disabling a user only in an external identity provider is outside this change.

ScienceMesh invitations use an email address without requiring an OpenCloud user, so they skip the recipient lookup.

Lookup errors skip the recipient. Grouped-email events are still removed before delivery and are not retried after a later lookup or SMTP failure.

How Has This Been Tested?

Unit tests and static checks

  • Notification package tests and service race tests pass, including disablement after events are stored and recipient lookup failures.
  • Static checks pass for the changed notification code.

Acceptance tests

Local runs with Inbucket compare the same source base without and with the fix:

  • Seven regression scenarios fail without the fix and pass with it.
  • Active recipients still receive notifications.
  • The new acceptance scenarios pass with POSIX and decomposed storage.
  • The full emailNotification.feature passes with decomposed storage.
  • The removed expected-failure entries cover space-membership expiry and share-removal emails; both tests already pass without this fix.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

🤖 drafted with OpenAI Codex, reviewed before submitting.

An empty mailbox can satisfy an immediate count assertion before an
asynchronous notification arrives, hiding unwanted email delivery.

Add a bounded observation step using the existing Inbucket helper.
Check throughout the observation period and fail when the count differs.
Email notifications can reach disabled users because GetUser does not
apply the configured LDAP filters for disabled users. Grouped emails
also use the recipient address stored when the events were queued.

Look up the recipient again through GetUserByClaim before delivery.
This lookup applies the LDAP filters and uses the existing lookup cache.
Recheck the global notification setting and use the returned email
address. Skip unavailable recipients and log lookup failures without
stopping delivery to other recipients. ScienceMesh invitations use the
recipient email address from the event without looking up the recipient.

Test the internal notification handlers and daily and weekly grouped
emails with active users, unavailable recipients, and lookup failures.

Related: opencloud-eu#3513
The earlier notification fixes removed these expected failures from
the POSIX list but left the two email cases in the decomposed list.
Both scenarios pass on the unpatched source base, so the acceptance
runner rejects them as unexpected successes.

Match the decomposed email expectations to POSIX. Keep the separate
in-app notification entry, which the email tests do not cover.

Related: opencloud-eu#3257
The existing email scenarios do not check delivery after a user is
disabled. An immediate empty-mailbox assertion can also miss email
that arrives asynchronously.

Extend the existing email feature to cover direct and group shares with
cold and expired lookup caches, daily and weekly grouped emails, and
file-share removal. Check that active users still receive email and
observe disabled recipients' mailbox counts for a bounded period.

Use a Graph mention step to check active delivery and the existing API
rejection of disabled recipients. The unit tests separately check that
events are queued before the recipient is disabled.

Related: opencloud-eu#3513
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 74 complexity

Metric Results
Complexity 74

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

1 participant