insertPinEventMessage static method
Implementation
static Future<void> insertPinEventMessage({
required String messageId,
String? conversationId,
String? creator,
int? timestamp,
}) async {
String? localConversationId = conversationId;
String? localCreator = creator;
if (localConversationId == null || localCreator == null) {
Message? pinedMsg = await ChatSDKService.instance.loadMessage(
messageId: messageId,
);
if (pinedMsg == null) {
return;
}
localConversationId = pinedMsg.conversationId!;
localCreator = ChatSDKService.instance.currentUserId!;
}
Message alertMsg = Message.createCustomSendMessage(
targetId: localConversationId,
event: alertPinMessageKey,
chatType: ChatType.GroupChat,
params: {
alertOperatorIdKey: localCreator,
},
);
int time = timestamp ?? DateTime.now().millisecondsSinceEpoch - 1;
alertMsg.conversationId = localConversationId;
alertMsg.serverTime = time + 1;
alertMsg.localTime = time + 1;
alertMsg.status = MessageStatus.SUCCESS;
await ChatSDKService.instance.insertMessage(
message: alertMsg,
runMessageReceived: true,
needUpdateConversationList: true,
);
}