Skip to content

Commit 61509c9

Browse files
committed
fix(feishu): handle anonymous user mentions
1 parent 8a90c86 commit 61509c9

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

scripts/feishu/markdown.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,7 @@ function replaceCitations(markdown, { context, format }) {
465465

466466
let label
467467
if (attributes.type === 'user') {
468-
if (!attributes['user-name']) {
469-
throw new Error(`${context} user citation is missing a name`)
470-
}
471-
label = `@${attributes['user-name']}`
468+
label = `@${attributes['user-name'] || '飞书用户'}`
472469
} else if (attributes.type === 'doc') {
473470
label = `《${attributes.title || attributes['doc-id'] || '飞书文档'}》`
474471
} else {

scripts/feishu/markdown.test.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ test('converts Feishu title, task list, chat card, and document citation blocks'
209209
'<title>飞书导出标题</title>\n\n' +
210210
'<chat_card name="AI Infra学习小组" chat-id="oc_123"></chat_card>\n\n' +
211211
'<readonly-block token="task_123" type="task_list"></readonly-block>\n\n' +
212-
'<cite doc-id="Wiki_123" file-type="wiki" title="会议议程" type="doc"></cite>\n',
212+
'<cite doc-id="Wiki_123" file-type="wiki" title="会议议程" type="doc"></cite>\n\n' +
213+
'<cite user-id="ou_hidden" type="user"></cite>\n',
213214
{
214215
contextLabel: 'Wiki page 示例',
215216
wikiRoutes: new Map()
@@ -220,6 +221,7 @@ test('converts Feishu title, task list, chat card, and document citation blocks'
220221
assert.match(output, /\*\*\*\* AI Infra/)
221222
assert.match(output, /> /)
222223
assert.match(output, //)
224+
assert.match(output, /@/)
223225
})
224226

225227
test('rejects unsafe attributes and unsupported markup inside tables', async () => {

0 commit comments

Comments
 (0)