mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 19:15:47 +00:00
refactor: dedupe gateway push string helper
This commit is contained in:
parent
f11005de45
commit
e5be7c2cd4
1 changed files with 3 additions and 10 deletions
|
|
@ -10,16 +10,9 @@ import {
|
|||
} from "../../infra/push-apns.js";
|
||||
import { ErrorCodes, errorShape, validatePushTestParams } from "../protocol/index.js";
|
||||
import { respondInvalidParams, respondUnavailableOnThrow } from "./nodes.helpers.js";
|
||||
import { normalizeTrimmedString } from "./record-shared.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
function normalizeOptionalString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
return trimmed.length > 0 ? trimmed : undefined;
|
||||
}
|
||||
|
||||
export const pushHandlers: GatewayRequestHandlers = {
|
||||
"push.test": async ({ params, respond }) => {
|
||||
if (!validatePushTestParams(params)) {
|
||||
|
|
@ -37,8 +30,8 @@ export const pushHandlers: GatewayRequestHandlers = {
|
|||
return;
|
||||
}
|
||||
|
||||
const title = normalizeOptionalString(params.title) ?? "OpenClaw";
|
||||
const body = normalizeOptionalString(params.body) ?? `Push test for node ${nodeId}`;
|
||||
const title = normalizeTrimmedString(params.title) ?? "OpenClaw";
|
||||
const body = normalizeTrimmedString(params.body) ?? `Push test for node ${nodeId}`;
|
||||
|
||||
await respondUnavailableOnThrow(respond, async () => {
|
||||
const registration = await loadApnsRegistration(nodeId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue