forwardChatItems method
- ChatId from,
- ChatId to,
- List<
ChatItemQuoteInput> items, { - ChatMessageText? text,
- List<
AttachmentId> ? attachments,
override
Forwards ChatItems to the specified Chat by the authenticated MyUser.
Supported ChatItems are ChatMessage and ChatForward.
If text
or attachments
argument is specified, then the forwarded
ChatItems will be followed with a posted ChatMessage containing that
text
and/or attachments
.
Implementation
@override
Future<void> forwardChatItems(
ChatId from,
ChatId to,
List<model.ChatItemQuoteInput> items, {
ChatMessageText? text,
List<AttachmentId>? attachments,
}) async {
Log.debug(
'forwardChatItems($from, $to, $items, $text, $attachments)',
'$runtimeType',
);
if (to.isLocal) {
to = (await ensureRemoteDialog(to))!.id;
}
try {
// TODO: Implement posting local [ChatForward]s with sending status:
// https://github.com/team113/messenger/issues/1347
await _graphQlProvider.forwardChatItems(
from,
to,
items
.map(
(i) => ChatItemQuoteInput(
id: i.item.id,
attachments: i.attachments,
withText: i.withText,
),
)
.toList(),
text: text,
attachments: attachments,
);
} on ForwardChatItemsException catch (e) {
switch (e.code) {
case ForwardChatItemsErrorCode.blocked:
case ForwardChatItemsErrorCode.noTextAndNoAttachment:
case ForwardChatItemsErrorCode.unknownUser:
case ForwardChatItemsErrorCode.unknownForwardedAttachment:
case ForwardChatItemsErrorCode.wrongItemsCount:
case ForwardChatItemsErrorCode.unsupportedForwardedItem:
case ForwardChatItemsErrorCode.unknownForwardedItem:
case ForwardChatItemsErrorCode.unknownAttachment:
case ForwardChatItemsErrorCode.artemisUnknown:
rethrow;
case ForwardChatItemsErrorCode.unknownChat:
// No-op, as either `from` or `to` chat doesn't exist - which one is
// unknown.
break;
}
}
}