diff --git a/src/main/message-parser.ts b/src/main/message-parser.ts index 3daee7a..51a34af 100644 --- a/src/main/message-parser.ts +++ b/src/main/message-parser.ts @@ -550,6 +550,15 @@ function parseShareMessage(content: string): ParsedContent { if (/]+>/g, ' ')) || '客服消息', + raw: content + } + } + return { + type: 'share', + title: title || '客服消息', + des: des || undefined, + url: url || '', + appname, + typeVal: extractAppMsgType(content) || 'kefu' + } +} + function parseShareArticles(content: string): ShareArticle[] { if (!/ { }) }) + it('parses music share cards from song/album fields', () => { + const xml = [ + '', + '3', + '<![CDATA[晴天]]>', + '', + '', + '', + '', + '' + ].join('') + const parsed = parseMessageContent(xml, 49) + expect(parsed).toMatchObject({ + type: 'share', + title: '晴天', + des: '周杰伦', + url: 'https://music.example/song', + appname: '音乐', + typeVal: '3' + }) + }) + + it('parses subscribe template cards', () => { + const clean = [ + '', + '', + '', + '', + '', + '' + ].join('') + const parsed = parseMessageContent(clean, 49) + expect(parsed).toMatchObject({ + type: 'share', + title: '服务通知', + des: '您的订单已发货', + appname: '订阅消息', + typeVal: 'subscribe' + }) + }) + + it('parses kefu template cards and falls back to system text', () => { + const card = [ + '', + '', + '', + '', + '' + ].join('') + expect(parseMessageContent(card, 49)).toMatchObject({ + type: 'share', + title: '店铺客服', + des: '点击查看订单', + typeVal: 'kefu' + }) + const menu = '' + expect(parseMessageContent(menu, 49)).toMatchObject({ + type: 'system', + content: '客服消息' + }) + }) + it('parses transfer wcpayinfo fields (type 2000)', () => { // 2026-09 真机转账采样字段名(含微信原文 transcationid 拼写) const xml = [