feat: 任务一键推送企微(总群+KOC个人直达+群发,含推送记录)

This commit is contained in:
ABAPPLO
2026-09-01 17:30:47 +08:00
parent b243562e60
commit d01281fba9
10 changed files with 1103 additions and 12 deletions

View File

@@ -84,8 +84,23 @@ test("parse callback xml handles CDATA and plain fields", () => {
assert.equal(extractWecomEncryptField(body), "RW5jcnlwdGVkQmFzZTY0PT0=");
});
test("event dispatcher classifies template_card mark_handled and ignores others", () => {
const ack = handleWecomCallbackEvent({
test("event dispatcher classifies template_card mark_handled and ignores others", async () => {
const inserts = [];
const fakeDb = {
prepare(sql) {
return {
bind(...params) {
return {
async run() {
inserts.push({ sql, params });
return { success: true };
},
};
},
};
},
};
const ack = await handleWecomCallbackEvent(fakeDb, {
MsgType: "event",
Event: "template_card_event",
TaskId: "task:t123:due",
@@ -96,8 +111,12 @@ test("event dispatcher classifies template_card mark_handled and ignores others"
assert.equal(ack.action, "card_ack");
assert.equal(ack.taskId, "task:t123:due");
assert.equal(ack.operator, "opsUser01");
assert.equal(inserts.length, 1);
assert.match(inserts[0].sql, /INSERT INTO wecom_push_logs/);
assert.equal(inserts[0].params[0].startsWith("wpl-"), true);
assert.equal(inserts[0].params[1], "t123");
const view = handleWecomCallbackEvent({
const view = await handleWecomCallbackEvent(fakeDb, {
MsgType: "event",
Event: "template_card_event",
TaskId: "task:t123:due",
@@ -106,7 +125,7 @@ test("event dispatcher classifies template_card mark_handled and ignores others"
assert.equal(view.recognized, true);
assert.equal(view.action, "ignored");
const other = handleWecomCallbackEvent({
const other = await handleWecomCallbackEvent(fakeDb, {
MsgType: "event",
Event: "change_contact",
});