fix(notifications): exclude the comment actor so they never self-notify#87
Merged
Conversation
When a user commented on a page inside an entity they owned, they received a
notification for their own comment whenever the owner was a group they belong
to. The owner-side event addressed the owning entity (a group), and Backstage's
recipient resolver expanded that group back to its members — including the
actor.
The publisher had only ever excluded the actor by literal ref
(`recipients.filter(ref => ref \!== actorRef)`), which a group owner ref can
never match. Forward the actor as `excludeEntityRef` on the notification
recipients instead: Backstage's resolver drops the actor from the resolved set
after expanding groups, covering group, nested-group, and direct-user owners
alike. This is the field's documented purpose ("the currently logged-in user,
for preventing sending notification of user action to him/herself").
With exclusion now correct at delivery, the publisher's literal-ref pre-filter
(and its empty-recipients early-exit) was redundant — `excludeEntityRef` is a
strict superset. Remove it so actor exclusion has a single home: the publisher
emits the raw section owner / thread participants (which may include the actor)
and the resolver drops the actor. Trade-off: self-comments and sole-participant
threads now publish an event that resolves to zero recipients instead of being
skipped locally; the wasted work is one publish + one notification POST (no
catalog expansion for the direct-user case).
Validates `actorRef` in the subscriber's shape guard (the sole basis for
exclusion now) and adds regression coverage, including an owner==actor publisher
test that fails if the literal filter is reintroduced.
Verified e2e: a group member commenting on their own entity gets nothing; a
non-member still notifies the member owners; an owner commenting on a directly
owned entity gets nothing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
When a user commented on a page inside an entity they owned, they received a notification for their own comment whenever the owner was a group they belong to. The owner-side
rw.commentsevent addressed the owning entity (the group), and Backstage's recipient resolver expanded that group back to its members — including the actor.Root cause: the publisher excluded the actor only by literal ref (
recipients.filter(ref => ref !== actorRef)), which a group owner ref can never match.Fix
Forward the actor as
excludeEntityRefon the notification recipients. Backstage's resolver drops the actor from the resolved set after expanding groups, covering group, nested-group, and direct-user owners alike — the field's documented purpose ("the currently logged-in user, for preventing sending notification of user action to him/herself").With exclusion correct at delivery, the publisher's literal-ref pre-filter was redundant (
excludeEntityRefis a strict superset), so it's removed: actor exclusion now has a single home. The publisher emits the raw section owner / thread participants (which may include the actor) and the resolver drops the actor.Trade-off: self-comments and sole-participant threads now publish an event that resolves to zero recipients instead of being skipped locally — one publish + one notification POST of wasted work (no catalog expansion for the direct-user case).
Tests
actorRefis now validated in the subscriber's shape guard (the sole basis for exclusion).Verification (e2e, dev app)
🤖 Generated with Claude Code