feat: 任务一键推送企微(总群+KOC个人直达+群发,含推送记录)
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import type { DatabaseClient } from "./database";
|
||||
import { recordCardAck } from "./task-one-click-push-service";
|
||||
|
||||
export type WecomCallbackFields = Record<string, string>;
|
||||
|
||||
export type WecomCallbackEventResult = {
|
||||
@@ -27,9 +30,10 @@ export function extractWecomEncryptField(body: string): string {
|
||||
return fields.Encrypt ?? "";
|
||||
}
|
||||
|
||||
export function handleWecomCallbackEvent(
|
||||
export async function handleWecomCallbackEvent(
|
||||
db: DatabaseClient,
|
||||
fields: WecomCallbackFields,
|
||||
): WecomCallbackEventResult {
|
||||
): Promise<WecomCallbackEventResult> {
|
||||
const event = fields.Event ?? "";
|
||||
const taskId = fields.TaskId ?? "";
|
||||
const btnKey = fields.BtnKey ?? "";
|
||||
@@ -37,10 +41,8 @@ export function handleWecomCallbackEvent(
|
||||
|
||||
if (fields.MsgType === "event" && event === "template_card_event") {
|
||||
if (btnKey === "mark_handled") {
|
||||
console.info(
|
||||
"[KOC LOOP] wecom card ack",
|
||||
{ taskId, operator },
|
||||
);
|
||||
await recordCardAck(db, { cardTaskId: taskId, btnKey, operator });
|
||||
console.info("[KOC LOOP] wecom card ack recorded", { taskId, operator });
|
||||
return { recognized: true, action: "card_ack", taskId, btnKey, operator };
|
||||
}
|
||||
return { recognized: true, action: "ignored", taskId, btnKey, operator };
|
||||
|
||||
Reference in New Issue
Block a user