mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 05:24:32 +00:00
refactor(channels): dedupe plugin routing and channel helpers
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user