WCFB 复用工作台企微打卡同步密钥

这个提交包含在:
2026-05-17 23:07:34 +08:00
父节点 1ccd675714
当前提交 bd601a6987
共修改 12 个文件,包含 158 行新增和 15 行删除
@@ -40,6 +40,13 @@ function sanitizeCheckinApiResponse(payload) {
return Object.keys(result).length ? result : null;
}
function resolveCheckinSecret(config) {
return (
toSafeString(config?.wecomCheckinSecret, 500) ||
toSafeString(config?.wecomAgentSecret, 500)
);
}
function normalizeCheckinRecord(raw, { employeeByExternalUserId, timeZone }) {
const externalUserId = toSafeString(raw?.userid ?? raw?.UserId, 128);
const employee = employeeByExternalUserId.get(externalUserId);
@@ -82,13 +89,14 @@ async function fetchWecomCheckinData({
response: null,
};
}
if (!toSafeString(config?.wecomCheckinSecret, 500)) {
const checkinSecret = resolveCheckinSecret(config);
if (!checkinSecret) {
return {
ok: false,
skipped: true,
retryable: false,
code: "wecom_checkin_secret_missing",
message: "Missing WECOM_CHECKIN_SECRET",
message: "Missing WECOM_CHECKIN_SECRET or WECOM_AGENT_SECRET",
records: [],
response: null,
};
@@ -108,7 +116,7 @@ async function fetchWecomCheckinData({
const tokenResult = await getWecomAppAccessToken({
config: {
...config,
wecomAgentSecret: config.wecomCheckinSecret,
wecomAgentSecret: checkinSecret,
},
timeoutMs: config.wecomRequestTimeoutMs ?? 5000,
fetchImpl,
@@ -177,5 +185,6 @@ module.exports = {
fetchWecomCheckinData,
formatDateInTimezone,
normalizeCheckinRecord,
resolveCheckinSecret,
sanitizeCheckinApiResponse,
};