feat(net-tool): 更新 LarkMessageService.update 方法,支持文本消息格式
All checks were successful
/ release (push) Successful in 25s

This commit is contained in:
zhaoyingbo 2025-01-14 09:11:53 +00:00
parent 82e3dde282
commit 42bd679248

View File

@ -55,12 +55,20 @@ class LarkMessageService extends LarkBaseService {
* @param messageId id
* @param content JSON结构序列化后的字符串msgType对应不同内容
*/
async update(messageId: string, content: string | Record<string, any>) {
async update(
messageId: string,
content: string | Record<string, any>,
isText: boolean = false
) {
const path = `/im/v1/messages/${messageId}`
if (typeof content === "object") {
content = JSON.stringify(content)
}
return this.patch<Lark.BaseRes>(path, { content })
if (isText && !content.includes('"text"')) {
content = JSON.stringify({ text: content })
}
if (!isText) return this.patch<Lark.BaseRes>(path, { content })
return this.put<Lark.BaseRes>(path, { content, msg_type: "text" })
}
/**