refactor(channels): dedupe plugin routing and channel helpers

This commit is contained in:
Peter Steinberger
2026-02-22 14:05:46 +00:00
parent 7abae052f9
commit 66f814a0af
57 changed files with 3744 additions and 2127 deletions

View File

@@ -11,12 +11,18 @@ function normalize(value?: string): string | undefined {
return trimmed ? trimmed : undefined;
}
function normalizeSenderLabelParams(params: SenderLabelParams) {
return {
name: normalize(params.name),
username: normalize(params.username),
tag: normalize(params.tag),
e164: normalize(params.e164),
id: normalize(params.id),
};
}
export function resolveSenderLabel(params: SenderLabelParams): string | null {
const name = normalize(params.name);
const username = normalize(params.username);
const tag = normalize(params.tag);
const e164 = normalize(params.e164);
const id = normalize(params.id);
const { name, username, tag, e164, id } = normalizeSenderLabelParams(params);
const display = name ?? username ?? tag ?? "";
const idPart = e164 ?? id ?? "";
@@ -28,11 +34,7 @@ export function resolveSenderLabel(params: SenderLabelParams): string | null {
export function listSenderLabelCandidates(params: SenderLabelParams): string[] {
const candidates = new Set<string>();
const name = normalize(params.name);
const username = normalize(params.username);
const tag = normalize(params.tag);
const e164 = normalize(params.e164);
const id = normalize(params.id);
const { name, username, tag, e164, id } = normalizeSenderLabelParams(params);
if (name) {
candidates.add(name);