refactor: dedupe tlon and voice-call lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 13:19:05 +01:00
parent 88b394ba1b
commit a93a94788a
10 changed files with 32 additions and 15 deletions

View File

@@ -1,5 +1,8 @@
import type { MsgContext } from "../auto-reply/templating.js";
import { normalizeOptionalString } from "../shared/string-coerce.js";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "../shared/string-coerce.js";
import { normalizeChatType } from "./chat-type.js";
function extractConversationId(from?: string): string | undefined {
@@ -60,7 +63,7 @@ export function resolveConversationLabel(ctx: MsgContext): string | undefined {
if (base.includes(id)) {
return base;
}
if (base.toLowerCase().includes(" id:")) {
if (normalizeLowercaseStringOrEmpty(base).includes(" id:")) {
return base;
}
if (base.startsWith("#") || base.startsWith("@")) {

View File

@@ -1,3 +1,5 @@
import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
export type ServicePrefix<TService extends string> = { prefix: string; service: TService };
export type ChatTargetPrefixesParams = {
@@ -94,7 +96,7 @@ export function resolveServicePrefixedTarget<TService extends string, TTarget>(p
if (!remainder) {
throw new Error(`${prefix} target is required`);
}
const remainderLower = remainder.toLowerCase();
const remainderLower = normalizeLowercaseStringOrEmpty(remainder);
if (params.isChatTarget(remainderLower)) {
return params.parseTarget(remainder);
}