mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-10 20:55:59 +08:00
Sync WhatsApp group subjects into access UI (4.9.1-ops.10).
Refresh missing/forced group titles via groupMetadata and participating catalog so cards show real names instead of bare JIDs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a169b164a8
commit
f96157da1e
13 changed files with 568 additions and 260 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { resolveWhatsappGroupSubject } from '../../../src/channels/whatsapp/whatsapp-identity.mjs';
|
||||
import {
|
||||
resolveWhatsappGroupSubject,
|
||||
resolveWhatsappGroupSubjects,
|
||||
} from '../../../src/channels/whatsapp/whatsapp-identity.mjs';
|
||||
|
||||
test('resolveWhatsappGroupSubject reads Baileys groupMetadata.subject', async () => {
|
||||
const subject = await resolveWhatsappGroupSubject({
|
||||
|
|
@ -13,6 +16,31 @@ test('resolveWhatsappGroupSubject reads Baileys groupMetadata.subject', async ()
|
|||
assert.equal(subject, '运维值班群');
|
||||
});
|
||||
|
||||
test('resolveWhatsappGroupSubject falls back to groupFetchAllParticipating', async () => {
|
||||
const subject = await resolveWhatsappGroupSubject({
|
||||
groupMetadata: async () => {
|
||||
throw new Error('forbidden');
|
||||
},
|
||||
groupFetchAllParticipating: async () => ({
|
||||
'120363429229984366@g.us': { id: '120363429229984366@g.us', subject: '告警群' },
|
||||
}),
|
||||
}, '120363429229984366@g.us');
|
||||
assert.equal(subject, '告警群');
|
||||
});
|
||||
|
||||
test('resolveWhatsappGroupSubjects batch-fills missing titles', async () => {
|
||||
const titles = await resolveWhatsappGroupSubjects({
|
||||
groupFetchAllParticipating: async () => ({
|
||||
'120363429229984366@g.us': { id: '120363429229984366@g.us', subject: 'A群' },
|
||||
'120363111111111111@g.us': { id: '120363111111111111@g.us', subject: 'B群' },
|
||||
}),
|
||||
}, ['120363429229984366@g.us', '120363111111111111@g.us']);
|
||||
assert.deepStrictEqual(titles, {
|
||||
'120363429229984366@g.us': 'A群',
|
||||
'120363111111111111@g.us': 'B群',
|
||||
});
|
||||
});
|
||||
|
||||
test('resolveWhatsappGroupSubject fails soft without socket metadata', async () => {
|
||||
assert.equal(await resolveWhatsappGroupSubject(null, '120363429229984366@g.us'), '');
|
||||
assert.equal(await resolveWhatsappGroupSubject({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue