perf: slim msteams store imports · openclaw/openclaw@6f74763
steipete
·
2026-04-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import crypto from "node:crypto"; |
2 | | -import { isRecord, readNestedString } from "./attachments/shared.js"; |
3 | 2 | import { resolveMSTeamsStorePath } from "./storage.js"; |
4 | 3 | import { readJsonFile, withFileLock, writeJsonFile } from "./store-fs.js"; |
5 | 4 | |
@@ -48,6 +47,18 @@ const STORE_FILENAME = "msteams-polls.json";
|
48 | 47 | const MAX_POLLS = 1000; |
49 | 48 | const POLL_TTL_MS = 30 * 24 * 60 * 60 * 1000; |
50 | 49 | |
| 50 | +function isRecord(value: unknown): value is Record<string, unknown> { |
| 51 | +return typeof value === "object" && value !== null && !Array.isArray(value); |
| 52 | +} |
| 53 | + |
| 54 | +function normalizeOptionalString(value: unknown): string | undefined { |
| 55 | +if (typeof value !== "string") { |
| 56 | +return undefined; |
| 57 | +} |
| 58 | +const trimmed = value.trim(); |
| 59 | +return trimmed ? trimmed : undefined; |
| 60 | +} |
| 61 | + |
51 | 62 | function normalizeChoiceValue(value: unknown): string | null { |
52 | 63 | if (typeof value === "string") { |
53 | 64 | const trimmed = value.trim(); |
@@ -87,6 +98,10 @@ function readNestedValue(value: unknown, keys: Array<string | number>): unknown
|
87 | 98 | return current; |
88 | 99 | } |
89 | 100 | |
| 101 | +function readNestedString(value: unknown, keys: Array<string | number>): string | undefined { |
| 102 | +return normalizeOptionalString(readNestedValue(value, keys)); |
| 103 | +} |
| 104 | + |
90 | 105 | export function extractMSTeamsPollVote( |
91 | 106 | activity: { value?: unknown } | undefined, |
92 | 107 | ): MSTeamsPollVote | null { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。