forward method

Future<bool> forward(
  1. List<String> targetRoomIds,
  2. Message msg, {
  3. ChatNewMessageNotification notification = const ChatNewMessageNotification(),
})

Implementation

Future<bool> forward(
  List<String> targetRoomIds,
  Message msg, {
  ChatNewMessageNotification notification =
      const ChatNewMessageNotification(),
}) async {
  if (me.isEmpty || targetRoomIds.isEmpty) return false;
  try {
    for (final id in targetRoomIds) {
      await createMessage(
        msg.copyWith(
          isForwarded: true,
          roomId: id,
          clearReplyId: true,
          createdAt: ChatValueTimestamp.now(),
          updatedAt: ChatValueTimestamp.now(),
        ),
        notification: notification,
      );
    }
    return true;
  } catch (e, st) {
    errorReporter.report(
      e,
      stackTrace: st,
      source: 'MessageMixin.forward',
      context: {'targetRoomIds': targetRoomIds, 'msgId': msg.id},
    );
    return false;
  }
}