addChatMember method

Future<ChatEventsVersionedMixin?> addChatMember(
  1. ChatId chatId,
  2. UserId userId
)

Adds an User to a Chat-group by the authority of the authenticated MyUser.

Authentication

Mandatory.

Result

Only the following ChatEvent may be produced on success:

Idempotent

Succeeds as no-op (and returns no ChatEvent) if the specified User is a member of the specified Chat already.

Implementation

Future<ChatEventsVersionedMixin?> addChatMember(
  ChatId chatId,
  UserId userId,
) async {
  Log.debug('addChatMember($chatId, $userId)', '$runtimeType');

  final variables = AddChatMemberArguments(chatId: chatId, userId: userId);
  var result = await client.mutate(
    MutationOptions(
      operationName: 'AddChatMember',
      document: AddChatMemberMutation(variables: variables).document,
      variables: variables.toJson(),
    ),
    onException: (data) => AddChatMemberException(
      (AddChatMember$Mutation.fromJson(data).addChatMember
              as AddChatMember$Mutation$AddChatMember$AddChatMemberError)
          .code,
    ),
  );
  return AddChatMember$Mutation.fromJson(result.data!).addChatMember
      as ChatEventsVersionedMixin?;
}