createMessageId static method

String createMessageId(
  1. String? hostName, {
  2. bool isChat = false,
  3. String? chatGroupId,
})

Generates a message ID

hostName the domain like 'example.com'

Set the optional isChat to true in case a COI-compliant message ID should be generated, in case of a group message also specify the chatGroupId.

chatGroupId the optional ID of the chat group in case the message-ID should be generated.

Implementation

static String createMessageId(
  String? hostName, {
  bool isChat = false,
  String? chatGroupId,
}) {
  String id;
  final random = createRandomId();
  id = isChat
      ? chatGroupId != null && chatGroupId.isNotEmpty
          ? '<chat\$group.$chatGroupId.$random@$hostName>'
          : '<chat\$$random@$hostName>'
      : '<$random@$hostName>';

  return id;
}