WREMOTE1 完成远端收口验证
这个提交包含在:
@@ -164,10 +164,20 @@ function normalizeFields(info) {
|
||||
.filter((item) => item.field_key);
|
||||
}
|
||||
|
||||
function extractUserId(value) {
|
||||
function extractUserId(value, depth = 0) {
|
||||
if (!value) return "";
|
||||
if (typeof value === "string") return toSafeString(value, 128);
|
||||
return pickText(value, ["userid", "user_id", "UserId", "UserID", "open_userid", "OpenUserId"], 128);
|
||||
if (depth > 3 || typeof value !== "object") return "";
|
||||
|
||||
const direct = pickText(value, ["userid", "user_id", "UserId", "UserID", "open_userid", "OpenUserId"], 128);
|
||||
if (direct) return direct;
|
||||
|
||||
for (const key of ["approver", "user", "member", "operator", "handler", "applyer", "applicant", "creator"]) {
|
||||
const nested = extractUserId(value[key], depth + 1);
|
||||
if (nested) return nested;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function normalizeParticipants(info) {
|
||||
|
||||
@@ -111,6 +111,36 @@ describe("wecomApprovalArchive", () => {
|
||||
expect(detail.detail_digest).toMatch(/^[0-9a-f]{64}$/);
|
||||
});
|
||||
|
||||
it("normalizes nested approval record approvers", () => {
|
||||
const nestedApprover = "nested_approver_full_userid_should_not_leak";
|
||||
const detail = normalizeApprovalDetailPayload(approvalPayload({
|
||||
sp_record: [{
|
||||
details: [{
|
||||
approver: { userid: nestedApprover },
|
||||
sp_status: "2",
|
||||
speech_time: "1779149800",
|
||||
speech: "同意",
|
||||
}],
|
||||
}],
|
||||
}), {
|
||||
source: "compensation_pull",
|
||||
target: "leave",
|
||||
});
|
||||
|
||||
expect(detail.participants).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
role: "approver",
|
||||
external_user_id: nestedApprover,
|
||||
}),
|
||||
]));
|
||||
expect(detail.actions).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
action_type: "approve",
|
||||
operator_external_user_id: nestedApprover,
|
||||
}),
|
||||
]));
|
||||
});
|
||||
|
||||
it("returns only masked public archive summaries", () => {
|
||||
const summary = publicArchiveSummary({
|
||||
id: "archive-1",
|
||||
|
||||
在新工单中引用
屏蔽一个用户