-
Notifications
You must be signed in to change notification settings - Fork 2
feat: implement api filter so users can only list public contact groups and related private contact groups #467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
scotwells
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoseSzycho should users be able to see private contact lists even if they're in the group? Seems like a private group should be private, even to end-users.
| // Use a custom response writer to capture the response | ||
| captureWriter := newCaptureResponseWriter(w) | ||
| handler.ServeHTTP(captureWriter, req) | ||
|
|
||
| // If the upstream handler didn't succeed, just forward the response | ||
| if captureWriter.statusCode != http.StatusOK { | ||
| captureWriter.flush() | ||
| return | ||
| } | ||
|
|
||
| // Filter the contact groups based on visibility | ||
| filteredBody, err := f.filterContactGroups(ctx, userID, captureWriter.body) | ||
| if err != nil { | ||
| responsewriters.InternalError(w, req, fmt.Errorf("failed to filter contact groups: %w", err)) | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoseSzycho could we inject a field selector here to force the caller to only retrieve Public Contact Groups? Seems like that's what is essentially happening in the f.filterContactGroups function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation follows the exact same behavior as the Loops Per-User Unsubscribe Page.
This is how Loops Per-User Unsubscribe Page works:
Public Groups:
- Visible to all users
Private Groups:
- Only visible to users who have an active subscription.
- These memberships are created manually by staff members, not by end-users.
User Workflow:
A user sees all public groups + any private groups they have subscription to.
If they unsubscribe from a private group (creates a ContactGroupMembershipRemoval), they lose that membership
The private group is then removed from their view and they cannot re-subscribe on their own.
This PR implements a visibility filter for ContactGroup resources that restricts which ContactGroups users can see when listing through their control-plane endpoint. Public groups are visible to everyone, while private groups are only visible to users who have an associated ContactGroupMembership.
Relates to
Closes #466