惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(feishu): send post mentions as native at elements (#9...
vincentkoc · 2026-06-16 · via Recent Commits to openclaw:main
11

// Feishu tests cover send plugin behavior.

22

import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

33

import type { ClawdbotConfig } from "../runtime-api.js";

4-

import { buildMarkdownCard } from "./send.js";

4+

import { buildFeishuPostMessagePayload, buildMarkdownCard } from "./send.js";

5566

const {

77

mockConvertMarkdownTables,

@@ -64,6 +64,49 @@ let listFeishuThreadMessages: typeof import("./send.js").listFeishuThreadMessage

6464

let resolveFeishuCardTemplate: typeof import("./send.js").resolveFeishuCardTemplate;

6565

let sendMessageFeishu: typeof import("./send.js").sendMessageFeishu;

666667+

describe("buildFeishuPostMessagePayload", () => {

68+

it("prepends structured mention targets as native post at elements", () => {

69+

const payload = buildFeishuPostMessagePayload({

70+

messageText: "hello **world**",

71+

mentions: [

72+

{ openId: "ou_alice", name: "Alice", key: "@_user_1" },

73+

{ openId: " ou_bob ", name: " Bob ", key: "@_user_2" },

74+

],

75+

});

76+77+

expect(payload.msgType).toBe("post");

78+

expect(JSON.parse(payload.content)).toEqual({

79+

zh_cn: {

80+

content: [

81+

[

82+

{ tag: "at", user_id: "ou_alice", user_name: "Alice" },

83+

{ tag: "at", user_id: "ou_bob", user_name: "Bob" },

84+

{ tag: "md", text: "hello **world**" },

85+

],

86+

],

87+

},

88+

});

89+

});

90+91+

it("leaves body-supplied at tags literal in the markdown element", () => {

92+

const payload = buildFeishuPostMessagePayload({

93+

messageText: 'please keep <at user_id="ou_body">Body User</at> literal',

94+

mentions: [{ openId: "ou_target", name: "Target User", key: "@_user_1" }],

95+

});

96+97+

expect(JSON.parse(payload.content)).toEqual({

98+

zh_cn: {

99+

content: [

100+

[

101+

{ tag: "at", user_id: "ou_target", user_name: "Target User" },

102+

{ tag: "md", text: 'please keep <at user_id="ou_body">Body User</at> literal' },

103+

],

104+

],

105+

},

106+

});

107+

});

108+

});

109+67110

describe("getMessageFeishu", () => {

68111

beforeAll(async () => {

69112

({

@@ -173,6 +216,51 @@ describe("getMessageFeishu", () => {

173216

});

174217

});

175218219+

it("sends automatic mentions as native post elements without rewriting body text", async () => {

220+

const create = vi.fn().mockResolvedValue({ code: 0, data: { message_id: "om_mentions" } });

221+

mockCreateFeishuClient.mockReturnValue({

222+

im: {

223+

message: {

224+

create,

225+

reply: vi.fn(),

226+

get: mockClientGet,

227+

list: mockClientList,

228+

patch: mockClientPatch,

229+

},

230+

},

231+

});

232+233+

const result = await sendMessageFeishu({

234+

cfg: {} as ClawdbotConfig,

235+

to: "oc_send",

236+

text: 'body <at user_id="ou_body">Body User</at>',

237+

mentions: [{ openId: "ou_target", name: "Target User", key: "@_user_1" }],

238+

});

239+240+

expect(mockConvertMarkdownTables).toHaveBeenCalledWith(

241+

'body <at user_id="ou_body">Body User</at>',

242+

"preserve",

243+

);

244+

expect(create).toHaveBeenCalledWith({

245+

params: { receive_id_type: "chat_id" },

246+

data: {

247+

receive_id: "oc_send",

248+

msg_type: "post",

249+

content: JSON.stringify({

250+

zh_cn: {

251+

content: [

252+

[

253+

{ tag: "at", user_id: "ou_target", user_name: "Target User" },

254+

{ tag: "md", text: 'body <at user_id="ou_body">Body User</at>' },

255+

],

256+

],

257+

},

258+

}),

259+

},

260+

});

261+

expect(result).toEqual({ messageId: "om_mentions", chatId: "oc_send" });

262+

});

263+176264

it("extracts text content from interactive card elements", async () => {

177265

mockClientGet.mockResolvedValueOnce({

178266

code: 0,