Clear a group and keep banned members

I’m looking for the best way to clear a group but keep its banned user list using the api. I’d prefer not to do it on behalf of any user, I am only looking to clean up a group.

Currently it looks like I’d need to do one of the following:

OR

Am I missing a better way? Is there something like the flush option for tokens with an option to keep banned members?

Hi @shawn,

The first approach from your post is much cleaner. I would suggest a few tweaks over it:

  1. To get the list of banned users, use:
    https://prodocs.cometchat.com/reference#listbannedgroupusers
    This doesn’t need onBehalfOfUID as a member of the group to call the API.
  2. Delete a group using:
    https://prodocs.cometchat.com/reference#deletegroup
  3. Recreate the group with the same GUID using:
    https://prodocs.cometchat.com/reference#creategroup
  4. Ban the members from the group without adding them to the group using:
    https://prodocs.cometchat.com/reference#add-members
    By sending UID of the users to ban as an array to usersToBan body param.

Feel free to let us know if you face any issues with CometChat Pro.

Warm regards,

Ketan Yekale
CometChat Pro

2 Likes

Thank you. I’m not sure how I missed those array options available with: https://prodocs.cometchat.com/reference#add-members
Sometimes a second set of eyes is all it takes :grinning:

2 Likes

@ketan.yekale Can I ask a follow up question, is it possible to get a list of all the users with a specific role without using a onBehalfOfUID?

This (https://prodocs.cometchat.com/reference#listusers) doesn’t show the ability to pass a role

Thank you @shawn, for pointing this out.

I’ll try to push this to our next API fixes. Meanwhile please keep using onBehalfOfUID to filter users as per the role.

Warm Regards,

Ketan Yekale
CometChat Pro

Ok sounds good, do you know a rough date when I should look for it?

The onBehalfOfUID version excludes the user that the onBehalfOfUID is for in the result, the https://prodocs.cometchat.com/reference#listusers version will not do that, correct?

1 Like

@ketan.yekale Is it possible to send a message to a group via the REST api without the use of onBehalfOfUID?

1 Like

Hi @shawn,

The onBehalfOfUID is the sender of the message without whom the message cannot be sent.

For listing all the users via API you can use list users API without onBehalfOfUID and this now accepts role as query param to list users with a specific role:
https://prodocs.cometchat.com/reference#listusers

Warm Regards,

Ketan Yekale
CometChat Pro

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.