createMiniProgramMessage method

Message createMiniProgramMessage({
  1. required int talkMode,
  2. required int toFromId,
  3. required String content,
  4. String? toolName,
  5. bool flashRead = false,
  6. String? quoteMsgId,
})

创建小程序消息(msg_type=14)。flashRead 为 true 时服务端按闪阅处理(需 flash_read.auto_recall_seconds>0);也可在 content JSON 中带 openType=browser。

Implementation

Message createMiniProgramMessage({
  required int talkMode,
  required int toFromId,
  required String content,
  String? toolName,
  bool flashRead = false,
  String? quoteMsgId,
}) {
  return Message(
    msgId: genMsgId(),
    msgType: MsgType.miniProgram,
    talkMode: talkMode,
    toFromId: toFromId,
    extra: {
      'content': content,
      if (toolName != null && toolName.isNotEmpty) 'tool_name': toolName,
      if (flashRead) 'flash_read': true,
    },
    quote: quoteMsgId != null ? {'quote_id': quoteMsgId} : null,
    sendTime: _now(),
    status: 1,
    fromId: _store.ownerId,
  );
}