sendMessage static method

OutboundOperation sendMessage({
  1. required String messageId,
  2. required String conversationId,
  3. required String content,
  4. MessageType? type,
  5. String? replyToId,
  6. List<PendingAttachment>? attachments,
  7. String? nonce,
  8. Map<String, dynamic>? extra,
})

Helper to create a send message operation.

Implementation

static OutboundOperation sendMessage({
  required String messageId,
  required String conversationId,
  required String content,
  MessageType? type,
  String? replyToId,
  List<PendingAttachment>? attachments,
  String? nonce,
  Map<String, dynamic>? extra,
}) {
  return OutboundOperation(
    id: DateTime.now().millisecondsSinceEpoch.toString(),
    type: OutboundOperationType.sendMessage,
    data: jsonEncode({
      'messageId': messageId,
      'conversationId': conversationId,
      'content': content,
      'type': type?.name,
      'replyToId': replyToId,
      'attachments': attachments
          ?.map(
            (a) => {
              'filePath': a.filePath,
              'fileName': a.fileName,
              'mimeType': a.mimeType,
            },
          )
          .toList(),
      'nonce': nonce,
      'extra': extra,
    }),
  );
}