Handle group chat permissions
Robust group chat permissions are key to providing users with a friendly and safe group chat experience.
Available permissions and options
These are the permissions allowed for a group:
- Add member
- Remove member
- Update metadata
- Add admin
- Remove admin
- Update permissions
These are the permission options available for each permission:
- Unspecified
- Allow
- Deny
- Allow if admin or super admin
- Allow if super admin
You can list, add, and remove members from a group chat. Only the group chat creator (super admin) has permission to add or remove members. This restriction ensures that only authorized individuals can modify the participant list.
Manage group chat admins
There are two kinds of administrators: super admins and admins. The group creator starts as a super admin, who has the most permissions so that a normal admin cannot remove the creator or destroy a group.
While group membership is inherent to the MLS group, administrators are specified through the group metadata. Updating the metadata is how you add or remove admins and specify who are admins versus super admins.
Here's an overview of how group chat admin statuses work:
- Everyone in a group chat is a member.
- A member can be granted admin or super admin status.
If the member's admin or super admin status is removed, they are still a member of the group chat. - By default, only a member with super admin can add and remove admin and super admin statuses.
Also by default, the group creator is the only member with super admin status.
Check if inbox ID is an admin
// Assume group is an existing group chat object for client
const isAdmin = await.group.isAdmin(adminClient.inboxID)
Check if inbox ID is a super admin
//Assume group is an existing group chat object for client
const isSuperAdmin = await group.isSuperAdmin(client.inboxID);
List admins
await group.listAdmins();
List super admins
await group.listSuperAdmins();
Add admin status to inbox ID
await group.addAdmin(client.inboxID);
Add super admin status to inbox ID
await group.addSuperAdmin(client.inboxID);
Remove admin status from inbox ID
await group.removeAdmin(client.inboxID);
Remove super admin status from inbox ID
await group.removeSuperAdmin(client.inboxId);
Manage group chat membership
Add members by inbox ID
await group.addMemberInboxIds([inboxId]);
Add members by address
await group.addMembers([walletAddress]);
Remove members by inbox ID
await group.removeMemberInboxIds([inboxId]);
Remove members by address
await group.removeMembers([walletAddress]);
Get inbox IDs for members
await group.memberInboxIds();
Get addresses for members
const members = await group.members();
const addresses = members.map((member) => member.addresses);
Get the inbox ID that added the current member
// this API is experimental and may change in the future
const addedByInboxId =await group.addedByInboxId();
SDK method call flow to add and remove members
When you add or remove members from a group, a proposal/commit message is sent to all the installations in the group. When the commit happens, the cryptographic state of the group is changed. This allows new members to receive messages but not decrypt older ones and prevents removed members from decrypting messages after their departure.