Skip to content

Commit c24246c

Browse files
authored
refactor: unify group operation endpoints (#292)
1 parent a34d0dc commit c24246c

File tree

14 files changed

+1554
-1320
lines changed

14 files changed

+1554
-1320
lines changed

Cargo.lock

Lines changed: 374 additions & 276 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apiclient/src/ds_api/mod.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ use phnxtypes::{
2929
WelcomeInfoParams,
3030
},
3131
client_ds_out::{
32-
AddClientsParamsOut, AddUsersParamsOut, ClientToDsMessageOut, ClientToDsMessageTbsOut,
32+
AddClientsParamsOut, ClientToDsMessageOut, ClientToDsMessageTbsOut,
3333
CreateGroupParamsOut, DeleteGroupParamsOut, DsMessageTypeOut, DsProcessResponseIn,
34-
DsRequestParamsOut, ExternalCommitInfoIn, JoinConnectionGroupParamsOut,
35-
JoinGroupParamsOut, RemoveClientsParamsOut, RemoveUsersParamsOut,
34+
DsRequestParamsOut, ExternalCommitInfoIn, GroupOperationParamsOut,
35+
JoinConnectionGroupParamsOut, JoinGroupParamsOut, RemoveClientsParamsOut,
3636
ResyncClientParamsOut, SelfRemoveClientParamsOut, SendMessageParamsOut,
3737
UpdateClientParamsOut,
3838
},
@@ -167,38 +167,15 @@ impl ApiClient {
167167
})
168168
}
169169

170-
/// Add one or more users to a group.
171-
pub async fn ds_add_users(
170+
/// Performs a group operation.
171+
pub async fn ds_group_operation(
172172
&self,
173-
payload: AddUsersParamsOut,
173+
payload: GroupOperationParamsOut,
174174
group_state_ear_key: &GroupStateEarKey,
175175
signing_key: &UserAuthSigningKey,
176176
) -> Result<TimeStamp, DsRequestError> {
177177
self.prepare_and_send_ds_group_message(
178-
DsRequestParamsOut::AddUsers(payload),
179-
signing_key,
180-
group_state_ear_key,
181-
)
182-
.await
183-
// Check if the response is what we expected it to be.
184-
.and_then(|response| {
185-
if let DsProcessResponseIn::FanoutTimestamp(ts) = response {
186-
Ok(ts)
187-
} else {
188-
Err(DsRequestError::UnexpectedResponse)
189-
}
190-
})
191-
}
192-
193-
/// Remove one or more users from a group.
194-
pub async fn ds_remove_users(
195-
&self,
196-
params: RemoveUsersParamsOut,
197-
group_state_ear_key: &GroupStateEarKey,
198-
signing_key: &UserAuthSigningKey,
199-
) -> Result<TimeStamp, DsRequestError> {
200-
self.prepare_and_send_ds_group_message(
201-
DsRequestParamsOut::RemoveUsers(params),
178+
DsRequestParamsOut::GroupOperation(payload),
202179
signing_key,
203180
group_state_ear_key,
204181
)

backend/src/ds/add_users.rs

Lines changed: 0 additions & 320 deletions
This file was deleted.

0 commit comments

Comments
 (0)