mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:30:45 +00:00
perf: slim msteams store imports
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import crypto from "node:crypto";
|
||||
import { isRecord, readNestedString } from "./attachments/shared.js";
|
||||
import { resolveMSTeamsStorePath } from "./storage.js";
|
||||
import { readJsonFile, withFileLock, writeJsonFile } from "./store-fs.js";
|
||||
|
||||
@@ -48,6 +47,18 @@ const STORE_FILENAME = "msteams-polls.json";
|
||||
const MAX_POLLS = 1000;
|
||||
const POLL_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function normalizeOptionalString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
return trimmed ? trimmed : undefined;
|
||||
}
|
||||
|
||||
function normalizeChoiceValue(value: unknown): string | null {
|
||||
if (typeof value === "string") {
|
||||
const trimmed = value.trim();
|
||||
@@ -87,6 +98,10 @@ function readNestedValue(value: unknown, keys: Array<string | number>): unknown
|
||||
return current;
|
||||
}
|
||||
|
||||
function readNestedString(value: unknown, keys: Array<string | number>): string | undefined {
|
||||
return normalizeOptionalString(readNestedValue(value, keys));
|
||||
}
|
||||
|
||||
export function extractMSTeamsPollVote(
|
||||
activity: { value?: unknown } | undefined,
|
||||
): MSTeamsPollVote | null {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import {
|
||||
readJsonFileWithFallback,
|
||||
withFileLock as withPathLock,
|
||||
writeJsonFileAtomically,
|
||||
} from "../runtime-api.js";
|
||||
import { withFileLock as withPathLock } from "openclaw/plugin-sdk/file-lock";
|
||||
import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
|
||||
|
||||
const STORE_LOCK_OPTIONS = {
|
||||
retries: {
|
||||
|
||||
Reference in New Issue
Block a user