Skip to content

Conversation

@blackheaven
Copy link
Contributor

@blackheaven blackheaven commented Sep 18, 2025

https://wearezeta.atlassian.net/browse/WPB-19712

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

WIP

  • Tests

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Sep 18, 2025
@blackheaven blackheaven marked this pull request as ready for review September 19, 2025 16:49
@blackheaven blackheaven requested a review from a team as a code owner September 19, 2025 16:49
Copy link
Collaborator

@eyeinsky eyeinsky left a comment

Choose a reason for hiding this comment

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

Just my comments, not all of them might be correct. Otherwise looks good and easy to read and understand.


type instance MapError 'UserGroupNotATeamAdmin = 'StaticError 403 "user-group-write-forbidden" "Only team admins can create, update, or delete user groups."

type instance MapError 'UserGroupChannelNotFound = 'StaticError 400 "user-group-channel-not-found" "Specified Channel does not exists or belongs to the team"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this could be a 404.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed, thanks.

lmap
(bimap toUUID (fmap toUUID))
$ [resultlessStatement|
delete from user_group_channel where user_group_id = ($1 :: uuid) and conv_id <> any($2 :: uuid[])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, testing on postgres console SELECT 1 <> ANY(ARRAY[1, 2, 3]); gives me true, so if an existing conversation is in the new set (part of the array) it would be deleted, but it's the other way around we want, don't we? (Unless I'm mistaken on what the logic should be.) Perhaps add this to the test to make sure.

Also, to my brain ... conv_id NOT IN (..new_conv_ids..) would be easier to read, rather than ... <> any(...) (but that may be just habit).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's also how my brain works... but not how hasql encoders work.

I guess it works because there is also an upsert operation following it.

I've tried something else.

);


ALTER TABLE public.user_group_member OWNER TO "wire-server";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this row need to be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped by mistake, thanks.

AddUser gid uid -> addUserImpl gid uid
UpdateUsers gid uids -> updateUsersImpl gid uids
RemoveUser gid uid -> removeUserImpl gid uid
UpdateUserGroupChannels _ gid convIds -> updateUserGroupChannelsImpl gid convIds
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe remove the TeamId field as it doesn't seem to be used (?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's used in the Mock interpreter (it's not a good idea though)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is not a good reason to have it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropped, I was thinking of the subsystem.

AddUser gid uid -> addUserImpl gid uid
UpdateUsers gid uids -> updateUsersImpl gid uids
RemoveUser gid uid -> removeUserImpl gid uid
UpdateUserGroupChannels _ gid convIds -> updateUserGroupChannelsImpl gid convIds
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is not a good reason to have it here.

@blackheaven blackheaven requested a review from battermann October 1, 2025 18:34
@blackheaven blackheaven force-pushed the gdifolco/WPB-19712_user-groups-update-endpoint branch from 4ed864c to 909912b Compare October 2, 2025 15:09
@blackheaven blackheaven force-pushed the gdifolco/WPB-19712_user-groups-update-endpoint branch from db1b267 to 2dea4d2 Compare October 8, 2025 08:51
Copy link
Contributor

@battermann battermann left a comment

Choose a reason for hiding this comment

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

LGTM

@blackheaven blackheaven requested review from a team as code owners October 8, 2025 13:26
@blackheaven
Copy link
Contributor Author

@copilot review this glorious PR please

@battermann battermann requested a review from Copilot October 8, 2025 13:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the ability for team admins to update channel associations for user groups, removing the previous stub implementation. The feature allows team admins to associate specific team channels with user groups via a PUT endpoint.

  • Replaces the stub implementation of updateUserGroupChannels with a full working implementation
  • Adds database schema and storage layer support for user group to channel associations
  • Implements validation to ensure only team channels can be associated with user groups

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
services/brig/src/Brig/API/Public.hs Removes stub implementation and adds real handler for updating user group channels
postgres-schema.sql Creates new user_group_channel table for storing channel associations
libs/wire-subsystems/src/Wire/UserGroupSubsystem/Interpreter.hs Implements business logic for channel validation and updates
libs/wire-subsystems/src/Wire/UserGroupStore/Postgres.hs Adds database operations for managing channel associations
libs/wire-api/src/Wire/API/Routes/Public/Brig.hs Updates API documentation to remove stub notation
integration/test/Test/UserGroup.hs Adds comprehensive test coverage for the new functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@blackheaven blackheaven merged commit d88aebb into develop Oct 8, 2025
8 checks passed
@blackheaven blackheaven deleted the gdifolco/WPB-19712_user-groups-update-endpoint branch October 8, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants