updateGroupDirectLink method
- ChatId groupId,
- 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:
- DirectLinkCreatedEvent, DirectLinkEnabledEvent,
DirectLinkDisabledEvent (if the
slugargument is notnull); - DirectLinkDisabledEvent (if the
slugargument isnullor absent).
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?);
}