Skip to content

scoped events: notify resource owner when an admin shares/unshares their resource #110

Description

@fabracht

Follow-up to #85 (PR #109). #85 routes a _shares grant/revoke event to the affected grantee's $DB/u/{grantee}/events/_shares/{id} namespace, so the grantee learns of gained/lost access without polling.

Gap

Only the grantee is notified. When an admin shares (or unshares) a resource on behalf of its owner, the resource owner is not notified that their resource's share set changed. In the common case the sharer is the owner (they initiated the share and already know), so #85 deliberately scoped notification to the grantee. But an admin-initiated share/unshare is a state change the owner may want to observe (e.g. to refresh a "shared with" list).

Where

event_recipients in crates/mqdb-agent/src/database/sharing.rs currently returns only [grantee] for a _shares event. To also notify the owner, resolve the governing resource's owner (resource_entity/resource_id are on the _shares record) and add it to the recipient list — de-duplicated, and skipping the case where the owner is the sharer to avoid a self-notification.

Considerations

  • Avoid notifying the owner when the owner is the one performing the share (no self-notification for the normal owner-initiated flow).
  • De-dup if the grantee happens to be the owner.
  • Agent-mode only (cluster sharing parity is tracked in cluster parity for diagram sharing #75).

Acceptance

  • Admin shares alice's resource with bob → both bob (grantee) and alice (owner) receive a _shares event on their scoped namespaces.
  • Owner-initiated share → only the grantee is notified (no self-notification), preserving scoped events: grantee not notified when a resource is shared or unshared #85 behavior.
  • Unit test on event_recipients covering owner + grantee, and the self-share no-op.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions