sendDirectMessage method
Future<ChatResult<ChatMessage> >
sendDirectMessage(
- String contactUserId, {
- String? text,
- MessageType messageType = MessageType.regular,
- String? referencedMessageId,
- String? reaction,
- String? attachmentUrl,
- Map<
String, dynamic> ? metadata,
override
Sends a direct message to a contact (creates a 1:1 room if needed).
Convenience wrapper around rooms.create + messages.send —
the backend resolves or creates the 1:1 room behind the scenes
and returns the message with its real id. Use this on the
"first message in a DM that has never been opened" path; for
subsequent messages in an existing DM prefer
ChatMessagesApi.sendViaWs against the resolved room id (cheaper
— no room-resolution round trip).
Implementation
@override
Future<ChatResult<ChatMessage>> sendDirectMessage(
String contactUserId, {
String? text,
MessageType messageType = MessageType.regular,
String? referencedMessageId,
String? reaction,
String? attachmentUrl,
Map<String, dynamic>? metadata,
}) async {
final msg = ChatMessage(
id: _client._nextMessageId(),
from: _client.currentUserId,
timestamp: DateTime.now(),
text: text,
messageType: messageType,
);
return ChatSuccess(msg);
}