Options
Menu

Class ChatPermissionManager

Allows getting and setting permissions for the various capabilities of Chats. The specific permissions are defined in ChatPermission. Permissions can be assigned per-DomainUser, per-UserGroup, or for everybody (setWorldPermissions).

Generally speaking, more specific permissions override less-specific ones. So a user's explicit permission would override the group's permission which the user is in, which would itself override any world permission for this Chat.

Hierarchy

  • ChatPermissionManager

Index

Accessors

chatId

  • get chatId(): string
  • The Chat ID to which these permissions apply.

    Returns string

Methods

addGroupPermissions

  • addGroupPermissions(permissions: object): Promise<void>
  • addGroupPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Adds the given permissions to any existing permissions for this chatId for all given groups.

    Parameters

    • permissions: object

      an object, mapping group IDs to an array of desired permission strings to be added

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

addUserPermissions

  • addUserPermissions(permissions: object): Promise<void>
  • addUserPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Adds the given permissions to any existing permissions for this chatId for all given users.

    Parameters

    • permissions: object

      an object, mapping usernames to an array of desired permission strings to be added

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

addWorldPermissions

  • Adds the given permissions to any existing WORLD permissions for this chatId.

    Parameters

    Returns Promise<void>

    A promise if successful

getAllGroupPermissions

  • Returns the permissions for all groups for this chatId.

    Returns Promise<Map<string, ChatPermission[]>>

    A promise, which resolves with a map of permission strings per group ID.

getAllUserPermissions

  • Returns the permissions for all users for this chatId.

    Returns Promise<Map<string, ChatPermission[]>>

    A promise, which resolves with a map of permission strings per username.

getGroupPermissions

  • Returns the permissions for the given group for this chatId.

    Parameters

    • groupId: string

      an existing group ID

    Returns Promise<ChatPermission[]>

    A promise, which resolves with an array of permission strings

getPermissions

  • Returns the resolved permissions for the current user for this chatId. Resolved means computed from the set of any relevant world, group or user permissions.

    Returns Promise<ChatPermission[]>

getUserPermissions

  • Returns the permissions for the given user for this chatId.

    Parameters

    • username: string

      an existing user's username

    Returns Promise<ChatPermission[]>

    A promise, which resolves with an array of permission strings

getWorldPermissions

  • Returns the permissions for WORLD for this chatId.

    Returns Promise<ChatPermission[]>

    A promise, which resolves with an array of permission strings

removeGroupPermissions

  • removeGroupPermissions(permissions: object): Promise<void>
  • removeGroupPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Removes the given permissions from any of the provided groups' permissions for this chatId.

    Parameters

    • permissions: object

      An object, mapping group IDs to an array of desired permission strings to be removed

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

removeUserPermissions

  • removeUserPermissions(permissions: object): Promise<void>
  • removeUserPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Removes the given permissions from any of the provided users' permissions for this chatId.

    Parameters

    • permissions: object

      An object, mapping usernames to an array of desired permission strings to be removed

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

removeWorldPermissions

  • removeWorldPermissions(permissions: ChatPermission[]): Promise<void>
  • Removes the given permissions from any existing WORLD permissions for this chatId.

    Parameters

    Returns Promise<void>

    A promise if successful

setGroupPermissions

  • setGroupPermissions(permissions: object): Promise<void>
  • setGroupPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Sets the given permissions for the given groups for this chatId.

    Parameters

    • permissions: object

      an object which maps one or more group IDs to their new set of permissions

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

setUserPermissions

  • setUserPermissions(permissions: object): Promise<void>
  • setUserPermissions(permissions: Map<string, ChatPermission[]>): Promise<void>
  • Sets the given permissions for the given users for this chatId.

    Parameters

    • permissions: object

      an object which maps one or more usernames to their new set of permissions

    Returns Promise<void>

    A promise if successful

  • Parameters

    Returns Promise<void>

setWorldPermissions

  • Sets the given permissions for WORLD for this chatId.

    Parameters

    Returns Promise<void>

    A promise if successful