18 lines
550 B
TypeScript
18 lines
550 B
TypeScript
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
|
|
|
export function resolveThreadBindingConversationIdFromBindingId(params: {
|
|
accountId: string;
|
|
bindingId?: string;
|
|
}): string | undefined {
|
|
const bindingId = normalizeOptionalString(params.bindingId);
|
|
if (!bindingId) {
|
|
return undefined;
|
|
}
|
|
const prefix = `${params.accountId}:`;
|
|
if (!bindingId.startsWith(prefix)) {
|
|
return undefined;
|
|
}
|
|
const conversationId = normalizeOptionalString(bindingId.slice(prefix.length));
|
|
return conversationId || undefined;
|
|
}
|