fix(notification): pass matched types to common inbox notifications - #11027
Open
dhaval-patel262 wants to merge 1 commit into
Open
fix(notification): pass matched types to common inbox notifications#11027dhaval-patel262 wants to merge 1 commit into
dhaval-patel262 wants to merge 1 commit into
Conversation
getCommonNotificationTxes() passed a hardcoded empty array as the `types` argument to pushInboxNotifications(), so every notification created through it was stored with `types: []`. NotificationsHandler resolves the allowed providers per notification type. With no types it matches no provider, logs "no notifications with email provider, skipping" and returns, so these notifications can never be delivered by email or any non-inbox provider. This affects everything routed through this helper - ToDos, process approvals (process:ids:ApproveRequestCreated), HR requests - while activity-message notifications are unaffected because that path passes its types through. The types are already computed: isShouldNotifyTx() returns a NotifyResult mapping each provider to the NotificationType docs that matched, and the result is passed in as notifyResult. Forward the inbox provider's types instead of discarding them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
getCommonNotificationTxes()passes a hardcoded empty array as thetypesargument topushInboxNotifications():https://github.com/hcengineering/platform/blob/develop/server-plugins/notification-resources/src/index.ts#L118-L134
Every notification created through this helper is therefore stored with
types: [].NotificationsHandlerresolves allowed providers per notification type — it iteratesnotification.types, looks each one up, and callsgetAllowedProviders(). With an empty array it evaluates nothing, logsNotificationsHandler: no notifications with email provider, skipping, and returns.The result: notifications created via this helper can never be delivered by email, or by any provider other than inbox — regardless of user settings or
defaultEnabledon the type.This affects everything routed through the helper —
timeToDos,processapprovals, HR requests. Activity-message notifications are unaffected, because that call site passes itstypesthrough, which is why chat notifications are emailed and ToDo/approval ones are not.Reproduce
mailservice and setMAIL_URLontransactorandaccount.RequestApprovalorCreateToDostep (process:ids:ApproveRequestCreated/process:ids:ProcessToDoCreated, bothdefaultEnabled: true).types: [], and the transactor logs the "skipping" line above.Fix
The types are already computed.
isShouldNotifyTx()returns aNotifyResult(Map<Ref<NotificationProvider>, NotificationType[]>) and it is passed into this function asnotifyResult— it is used on the line above to decide whether to proceed at all. Forward the inbox provider's matched types instead of discarding them:NotifyResultholds fullNotificationTypedocs whilepushInboxNotificationstakesRef<NotificationType>[], hence the.map. The?? []keeps the previous behaviour if the provider is somehow absent, though the guard clause above already returns early in that case.Verification
Applied against a self-hosted v0.7.423 transactor. Before, on an approval gate:
After:
and the mail service delivered to each collaborator. Inbox notifications are unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ws4kJfxwU8wq1yAgeix942