Skip to content

Conversation

@JoseSzycho
Copy link
Contributor

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

@JoseSzycho JoseSzycho linked an issue Dec 30, 2025 that may be closed by this pull request
@joggrbot
Copy link
Contributor

joggrbot bot commented Dec 30, 2025

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: aa1e0c7 | Powered by Joggr

@JoseSzycho JoseSzycho changed the title 466 implement api filter so users can only list public contact groups feat: implement api filter so users can only list public contact groups and related private contact groups Dec 30, 2025
Copy link
Contributor

@scotwells scotwells left a 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.

Comment on lines +81 to +96
// 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
}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scotwells

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.

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.

Implement API Filter so users can only list Public Contact Groups

3 participants