createMessage method
Future<Message>
createMessage(
- Message msg, {
- ChatSilentNotification notification = const ChatSilentNotification(),
- VerifyToSendMessage? verifyToSend,
- OnDeniedToSendMessage? onDeniedToSend,
Implementation
Future<Message> createMessage(
Message msg, {
ChatSilentNotification notification = const ChatSilentNotification(),
VerifyToSendMessage? verifyToSend,
OnDeniedToSendMessage? onDeniedToSend,
}) async {
final failed = msg.copyWith(status: MessageStatus.failed);
if (me.isEmpty || msg.isEmpty) return failed;
if (!isConnected && offlineQueueEnabled) {
final target = room(msg.roomId);
put(
target.copyWith(
lastMessage: msg.lastMessage(),
lastMessageId: msg.id,
lastMessageSenderId: me,
lastMessageDeleted: false,
updatedAt: ChatValueTimestamp.now(),
),
);
return enqueueMessage(
msg,
notification: notification,
verifyToSend: verifyToSend,
onDeniedToSend: onDeniedToSend,
);
}
return sendNow(
msg,
notification: notification,
verifyToSend: verifyToSend,
onDeniedToSend: onDeniedToSend,
);
}