-
Notifications
You must be signed in to change notification settings - Fork 334
WPB-19712: Allow team admin to update the channels to user-group association #4783
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
WPB-19712: Allow team admin to update the channels to user-group association #4783
Conversation
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.
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" |
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.
I guess this could be a 404.
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.
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[]) |
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.
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).
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.
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"; |
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.
Does this row need to be deleted?
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.
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 |
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.
Maybe remove the TeamId field as it doesn't seem to be used (?).
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.
it's used in the Mock interpreter (it's not a good idea though)
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.
I think that is not a good reason to have it here.
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.
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 |
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.
I think that is not a good reason to have it here.
libs/wire-subsystems/src/Wire/UserGroupSubsystem/Interpreter.hs
Outdated
Show resolved
Hide resolved
4ed864c to
909912b
Compare
libs/wire-subsystems/src/Wire/UserGroupSubsystem/Interpreter.hs
Outdated
Show resolved
Hide resolved
db1b267 to
2dea4d2
Compare
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.
LGTM
|
@copilot review this glorious PR please |
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.
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
updateUserGroupChannelswith 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.
https://wearezeta.atlassian.net/browse/WPB-19712
Checklist
changelog.dWIP