Skip to content

UN-3494 [GATED-FEAT] Email group members on share and membership change - #2224

Draft
kirtimanmishrazipstack wants to merge 2 commits into
mainfrom
UN-3494-group-sharing-notification
Draft

UN-3494 [GATED-FEAT] Email group members on share and membership change#2224
kirtimanmishrazipstack wants to merge 2 commits into
mainfrom
UN-3494-group-sharing-notification

Conversation

@kirtimanmishrazipstack

@kirtimanmishrazipstack kirtimanmishrazipstack commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What

  • Group members now get an email when a resource is shared with their group, and when they are added to or removed from a group.
  • New internal APIs under /internal/v1/group-notification/ plus two workers/notification tasks that call them.
  • Restores direct-user share emails, dead since sharing moved to POST /{id}/share/.

Why

  • Sharing a resource with a group granted access silently — members had no way to know.
  • _notify_shared_users was still wired to partial_update, which no client has called since UN-2977, so single-user share emails stopped going out entirely.

How

  • One hook in ResourceShareManagementMixin.share covers all 7 shareable resources plus cloud agentic; dispatch reuses resolve_transport (PG queue where pg_queue_enabled is on for the org, Celery otherwise).
  • Group expansion, OrganizationMember re-validation and the kind → ResourceType mapping live in the internal views, since workers/ has no Django.
  • Fails closed behind Flipt group_sharing_notifications_enabled — a blind Flipt, a missing org or any dispatch error means no email, never a broken share.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

  • Low risk: notification-only side effects, all wrapped, gated on a default-off Flipt flag. The one restored behavior (direct-user share email) is a return to pre-UN-2977 behavior. Membership changes with no actor — org-removal cascade, Django admin, group deletion — deliberately do not notify.

Database Migrations

  • None

Env Config

  • Flipt group_sharing_notifications_enabled — new, gates the whole feature. Off or unreachable means no emails.
  • Flipt pg_queue_enabled — existing, reused to pick PG queue vs Celery transport.
  • New worker-pg-notification compose service (pg-queue profile), with optional overrides PG_NOTIFICATION_CONCURRENCY, PG_NOTIFICATION_VT_SECONDS, PG_NOTIFICATION_HEALTH_STALE_SECONDS.

Relevant Docs

Related Issues or PRs

  • Zipstack/unstract-cloud#1698 — cloud half. Must merge at or before this PR.

Dependencies Versions

  • None

Notes on Testing

  • Verified manually against the dev DB: user, group and co-owner share paths all dispatch with the expected recipients and template data.

Screenshots

Checklist

I have read and understood the Contribution Guidelines.

…ship changes

Sharing a resource with a group gave its members access silently, and adding
or removing someone from a group told nobody. Both now send email.

- share_notifications.py holds the feature flag, the two task names and the two
  enqueue hooks. Dispatch uses the same resolve_transport branch the execution
  path uses: the PG queue where pg_queue_enabled is on for the org, Celery
  otherwise.
- One hook in ResourceShareManagementMixin.share covers all 7 resource types
  plus cloud agentic, including service-account shares — every group share
  funnels through it and shared_groups has no PATCH path. No on_commit needed:
  _commit's transaction has closed by the time the view resumes, so the diff
  reads committed state.
- Group membership hooks on the add and remove actions. The add serializer
  already subtracts existing members, so nobody is mailed twice.
- Internal endpoints under /internal/v1/group-notification/ do the work the
  worker cannot: group expansion, OrganizationMember re-validation (this is
  where the offboarding race closes), resource lookup via ShareableResource,
  and the kind -> ResourceType mapping, which is not 1:1 — pipelines split on
  pipeline_type and adapters four ways on adapter_type.
- Two worker tasks that only POST to that endpoint, since workers/ has no
  Django. They raise on failure, unlike _mark_buffer_outcome which has a reaper
  behind it, and retry transient 5xx in-task because a raise is terminal on the
  Celery transport.
- The whole feature is gated on Flipt group_sharing_notifications_enabled and
  fails closed: a blind Flipt, a missing org, or any dispatch error means no
  notification, never a broken share.
- worker-pg-notification compose service so the PG arm is not a black hole.

Membership changes with no actor (the org-removal cascade, Django admin, group
deletion) do not notify — SharingNotificationService requires an actor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f043d72-dd49-4fe1-94d3-310da9515161

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

UN-2977 moved sharing from PATCH to POST /{id}/share/, but the mixin's
share action only diffed the groups axis. The per-viewset
_notify_shared_users hooks stayed on partial_update, which nothing calls
anymore, so sharing a resource with a user sent no email.

Snapshot every declared axis and invoke the hook after the commit; declare
it on the mixin as a no-op for hosts without a direct-share email.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@kirtimanmishrazipstack kirtimanmishrazipstack changed the title UN-3494 [FEAT] Email group members on resource share and group member… UN-3494 [GATED-FEAT] Email group members on share and membership change Aug 4, 2026
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