@@ -251,6 +251,7 @@ func (c *Client) ExportUser(ctx context.Context, targetID string) (*ExportUserRe
251
251
252
252
type deactivateUserOptions struct {
253
253
MarkMessagesDeleted bool `json:"mark_messages_deleted"`
254
+ MarkChannelsDeleted bool `json:"mark_channels_deleted"`
254
255
CreatedByID string `json:"created_by_id"`
255
256
}
256
257
@@ -262,6 +263,12 @@ func DeactivateUserWithMarkMessagesDeleted() func(*deactivateUserOptions) {
262
263
}
263
264
}
264
265
266
+ func DeactivateUserWithMarkChannelsDeleted () func (* deactivateUserOptions ) {
267
+ return func (opt * deactivateUserOptions ) {
268
+ opt .MarkChannelsDeleted = true
269
+ }
270
+ }
271
+
265
272
func DeactivateUserWithCreatedBy (userID string ) func (* deactivateUserOptions ) {
266
273
return func (opt * deactivateUserOptions ) {
267
274
opt .CreatedByID = userID
@@ -286,8 +293,34 @@ func (c *Client) DeactivateUser(ctx context.Context, targetID string, options ..
286
293
return & resp , err
287
294
}
288
295
296
+ type deactivateUsersOptions struct {
297
+ UserIDs []string `json:"user_ids"`
298
+ deactivateUserOptions
299
+ }
300
+
301
+ // DeactivateUsers deactivates the users with the given target user IDs.
302
+ func (c * Client ) DeactivateUsers (ctx context.Context , targetIDs []string , options ... DeactivateUserOptions ) (* Response , error ) {
303
+ if len (targetIDs ) == 0 {
304
+ return nil , errors .New ("target IDs is empty" )
305
+ }
306
+
307
+ opts := & deactivateUsersOptions {
308
+ UserIDs : targetIDs ,
309
+ }
310
+ for _ , fn := range options {
311
+ fn (& opts .deactivateUserOptions )
312
+ }
313
+
314
+ p := path .Join ("users" , "deactivate" )
315
+
316
+ var resp Response
317
+ err := c .makeRequest (ctx , http .MethodPost , p , nil , opts , & resp )
318
+ return & resp , err
319
+ }
320
+
289
321
type reactivateUserOptions struct {
290
322
RestoreMessages bool `json:"restore_messages"`
323
+ RestoreChannels bool `json:"restore_channels"`
291
324
Name string `json:"name"`
292
325
CreatedByID string `json:"created_by_id"`
293
326
}
@@ -300,6 +333,12 @@ func ReactivateUserWithRestoreMessages() func(*reactivateUserOptions) {
300
333
}
301
334
}
302
335
336
+ func ReactivateUserWithRestoreChannels () func (* reactivateUserOptions ) {
337
+ return func (opt * reactivateUserOptions ) {
338
+ opt .RestoreChannels = true
339
+ }
340
+ }
341
+
303
342
func ReactivateUserWithCreatedBy (userID string ) func (* reactivateUserOptions ) {
304
343
return func (opt * reactivateUserOptions ) {
305
344
opt .CreatedByID = userID
@@ -330,6 +369,31 @@ func (c *Client) ReactivateUser(ctx context.Context, targetID string, options ..
330
369
return & resp , err
331
370
}
332
371
372
+ type reactivateUsersOptions struct {
373
+ UserIDs []string `json:"user_ids"`
374
+ reactivateUserOptions
375
+ }
376
+
377
+ // ReactivateUsers reactivates deactivated users with the given target user IDs.
378
+ func (c * Client ) ReactivateUsers (ctx context.Context , targetIDs []string , options ... ReactivateUserOptions ) (* Response , error ) {
379
+ if len (targetIDs ) == 0 {
380
+ return nil , errors .New ("target IDs is empty" )
381
+ }
382
+
383
+ opts := & reactivateUsersOptions {
384
+ UserIDs : targetIDs ,
385
+ }
386
+ for _ , fn := range options {
387
+ fn (& opts .reactivateUserOptions )
388
+ }
389
+
390
+ p := path .Join ("users" , "reactivate" )
391
+
392
+ var resp Response
393
+ err := c .makeRequest (ctx , http .MethodPost , p , nil , opts , & resp )
394
+ return & resp , err
395
+ }
396
+
333
397
type deleteUserOptions struct {
334
398
MarkMessagesDeleted string
335
399
HardDelete string
0 commit comments