createMessageId method Null safety

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;
  var random = createRandomId();
  if (isChat) {
    if (chatGroupId != null && chatGroupId.isNotEmpty) {
      id = '<chat\$group.$chatGroupId.$random@$hostName>';
    } else {
      id = '<chat\$$random@$hostName>';
    }
  } else {
    id = '<$random@$hostName>';
  }
  return id;
}