From 4e62bdf78db1e635e738378d0a3e00b6c3106c72 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 18 Feb 2026 23:32:48 +0000 Subject: [PATCH] refactor(signal): reuse shared reaction types --- src/signal/monitor.ts | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/signal/monitor.ts b/src/signal/monitor.ts index 98b8bd301d..baf45795c1 100644 --- a/src/signal/monitor.ts +++ b/src/signal/monitor.ts @@ -7,34 +7,21 @@ import type { SignalReactionNotificationMode } from "../config/types.js"; import { waitForTransportReady } from "../infra/transport-ready.js"; import { saveMediaBuffer } from "../media/store.js"; import { createNonExitingRuntime, type RuntimeEnv } from "../runtime.js"; +import { normalizeStringEntries } from "../shared/string-normalization.js"; import { normalizeE164 } from "../utils.js"; import { resolveSignalAccount } from "./accounts.js"; import { signalCheck, signalRpcRequest } from "./client.js"; import { spawnSignalDaemon } from "./daemon.js"; import { isSignalSenderAllowed, type resolveSignalSender } from "./identity.js"; import { createSignalEventHandler } from "./monitor/event-handler.js"; +import type { + SignalAttachment, + SignalReactionMessage, + SignalReactionTarget, +} from "./monitor/event-handler.types.js"; import { sendMessageSignal } from "./send.js"; import { runSignalSseLoop } from "./sse-reconnect.js"; -type SignalReactionMessage = { - emoji?: string | null; - targetAuthor?: string | null; - targetAuthorUuid?: string | null; - targetSentTimestamp?: number | null; - isRemove?: boolean | null; - groupInfo?: { - groupId?: string | null; - groupName?: string | null; - } | null; -}; - -type SignalAttachment = { - id?: string | null; - contentType?: string | null; - filename?: string | null; - size?: number | null; -}; - export type MonitorSignalOpts = { runtime?: RuntimeEnv; abortSignal?: AbortSignal; @@ -61,15 +48,9 @@ function resolveRuntime(opts: MonitorSignalOpts): RuntimeEnv { } function normalizeAllowList(raw?: Array): string[] { - return (raw ?? []).map((entry) => String(entry).trim()).filter(Boolean); + return normalizeStringEntries(raw); } -type SignalReactionTarget = { - kind: "phone" | "uuid"; - id: string; - display: string; -}; - function resolveSignalReactionTargets(reaction: SignalReactionMessage): SignalReactionTarget[] { const targets: SignalReactionTarget[] = []; const uuid = reaction.targetAuthorUuid?.trim();