updateGroupDirectLink method

Future<DirectLinkVersionedEventsMixin?> updateGroupDirectLink(
  1. ChatId groupId,
  2. DirectLinkSlug? slug
)

Creates, updates or disables the current DirectLink of the specified Chat-group.

Chat-group can have only a single enabled DirectLink at the time. The previous enabled DirectLink (if there is any already) will be automatically disabled.

If the slug argument is null or absent, then the current enabled DirectLink of the specified Chat-group will be disabled.

Disabled DirectLinks can be re-enabled again for the specified Chat-group, but can never ever leak to somebody else.

Authentication

Mandatory.

Result

Only the following DirectLinkEvents may be produced on success:

Idempotent

Succeeds as no-op (and returns no DirectLinkEvents) if the specified Chat-group has an enabled DirectLink with such DirectLinkSlug already, or has no enabled DirectLink already.

Implementation

Future<DirectLinkVersionedEventsMixin?> updateGroupDirectLink(
  ChatId groupId,
  DirectLinkSlug? slug,
) async {
  Log.debug('updateGroupDirectLink($groupId, $slug)', '$runtimeType');

  final variables = UpdateGroupDirectLinkArguments(
    slug: slug,
    groupId: groupId,
  );
  final QueryResult result = await client.mutate(
    MutationOptions(
      operationName: 'UpdateGroupDirectLink',
      document: UpdateGroupDirectLinkMutation(variables: variables).document,
      variables: variables.toJson(),
    ),
    onException: (data) => UpdateGroupDirectLinkException(
      (UpdateGroupDirectLink$Mutation.fromJson(data).updateGroupDirectLink
              as UpdateGroupDirectLink$Mutation$UpdateGroupDirectLink$UpdateGroupDirectLinkError)
          .code,
    ),
  );
  return (UpdateGroupDirectLink$Mutation.fromJson(
        result.data!,
      ).updateGroupDirectLink
      as DirectLinkVersionedEventsMixin?);
}