insertMessage method

Future<void> insertMessage({
  1. required Message message,
  2. bool runMessageReceived = false,
  3. bool needUpdateConversationList = false,
})

Implementation

Future<void> insertMessage({
  required Message message,
  bool runMessageReceived = false,
  bool needUpdateConversationList = false,
}) {
  return checkResult(ChatSDKEvent.importMessages, () async {
    Conversation? conversation =
        await Client.getInstance.chatManager.getConversation(
      message.conversationId ?? message.from!,
      type: ConversationType.values[message.chatType.index],
      createIfNeed: true,
    );
    await conversation!.insertMessage(message);
    if (runMessageReceived) {
      super.onMessagesReceived([message]);
    }
    if (needUpdateConversationList) {
      super.onConversationsUpdate();
    }
  });
}