diff --git a/src/server/model/notification/provider/__tests__/feishu.spec.ts b/src/server/model/notification/provider/__tests__/feishu.spec.ts new file mode 100644 index 0000000..8ff1dd6 --- /dev/null +++ b/src/server/model/notification/provider/__tests__/feishu.spec.ts @@ -0,0 +1,22 @@ +import { describe, test } from 'vitest'; +import { token } from '../../token/index.js'; +import { feishu } from '../feishu.js'; + +describe.runIf(!!process.env.TEST_FEISHU_URL)('feishu', () => { + test('apprise should be work', async () => { + await feishu.send( + { + payload: { + webhookUrl: process.env.TEST_FEISHU_URL, + }, + } as any, + 'test title', + [ + token.title('test title', 1), + token.text('list'), + token.newline(), + token.list([token.text('A'), token.text('B')]), + ] + ); + }); +}); diff --git a/src/server/model/notification/provider/feishu.ts b/src/server/model/notification/provider/feishu.ts index b35845a..5954e11 100644 --- a/src/server/model/notification/provider/feishu.ts +++ b/src/server/model/notification/provider/feishu.ts @@ -1,5 +1,5 @@ import { NotificationProvider } from './type.js'; -import { baseContentTokenizer } from '../token/index.js'; +import { markdownContentTokenizer } from '../token/index.js'; import axios from 'axios'; interface FeishuPayload { @@ -17,18 +17,16 @@ export const feishu: NotificationProvider = { throw new Error('Is not a valid feishu webhook url'); } - const content = baseContentTokenizer.parse(message); + const content = markdownContentTokenizer.parse(message); + // Document: https://open.larksuite.com/document/common-capabilities/message-card/message-cards-content/using-markdown-tags await axios.post(webhookUrl, { msg_type: 'interactive', card: { elements: [ { - tag: 'div', - text: { - content, - tag: 'plain_text', - }, + tag: 'markdown', + content, }, ], header: { @@ -36,6 +34,7 @@ export const feishu: NotificationProvider = { content: title, tag: 'plain_text', }, + template: 'blue', }, }, });