

























@@ -2,6 +2,7 @@ import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/ind
22import type { CallGatewayOptions } from "../../gateway/call.js";
33import { parseThreadSessionSuffix } from "../../sessions/session-key-utils.js";
44import { normalizeOptionalStringifiedId } from "../../shared/string-coerce.js";
5+import { deliveryContextFromSession } from "../../utils/delivery-context.shared.js";
56import type { SessionListRow } from "./sessions-helpers.js";
67import type { AnnounceTarget } from "./sessions-send-helpers.js";
78import { resolveAnnounceTargetFromKey } from "./sessions-send-helpers.js";
@@ -45,30 +46,10 @@ export async function resolveAnnounceTarget(params: {
4546sessions.find((entry) => entry?.key === params.sessionKey) ??
4647sessions.find((entry) => entry?.key === params.displayKey);
474848-const deliveryContext =
49-match?.deliveryContext && typeof match.deliveryContext === "object"
50- ? (match.deliveryContext as Record<string, unknown>)
51- : undefined;
52-const origin =
53-match?.origin && typeof match.origin === "object"
54- ? (match.origin as Record<string, unknown>)
55- : undefined;
56-const channel =
57-(typeof deliveryContext?.channel === "string" ? deliveryContext.channel : undefined) ??
58-(typeof match?.lastChannel === "string" ? match.lastChannel : undefined) ??
59-(typeof origin?.provider === "string" ? origin.provider : undefined);
60-const to =
61-(typeof deliveryContext?.to === "string" ? deliveryContext.to : undefined) ??
62-(typeof match?.lastTo === "string" ? match.lastTo : undefined);
63-const accountId =
64-(typeof deliveryContext?.accountId === "string" ? deliveryContext.accountId : undefined) ??
65-(typeof match?.lastAccountId === "string" ? match.lastAccountId : undefined) ??
66-(typeof origin?.accountId === "string" ? origin.accountId : undefined);
67-const threadId = normalizeOptionalStringifiedId(
68-deliveryContext?.threadId ?? match?.lastThreadId ?? origin?.threadId ?? fallbackThreadId,
69-);
70-if (channel && to) {
71-return { channel, to, accountId, threadId };
49+const context = deliveryContextFromSession(match);
50+const threadId = normalizeOptionalStringifiedId(context?.threadId ?? fallbackThreadId);
51+if (context?.channel && context.to) {
52+return { channel: context.channel, to: context.to, accountId: context.accountId, threadId };
7253}
7354} catch {
7455// ignore
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。