mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:41:38 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -6,7 +6,9 @@ const getGroupSurfaces = () => new Set<string>([...listDeliverableMessageChannel
|
||||
|
||||
function normalizeGroupLabel(raw?: string) {
|
||||
const trimmed = raw?.trim().toLowerCase() ?? "";
|
||||
if (!trimmed) return "";
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
const dashed = trimmed.replace(/\s+/g, "-");
|
||||
const cleaned = dashed.replace(/[^a-z0-9#@._+-]+/g, "-");
|
||||
return cleaned.replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
||||
@@ -14,8 +16,12 @@ function normalizeGroupLabel(raw?: string) {
|
||||
|
||||
function shortenGroupId(value?: string) {
|
||||
const trimmed = value?.trim() ?? "";
|
||||
if (!trimmed) return "";
|
||||
if (trimmed.length <= 14) return trimmed;
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
}
|
||||
if (trimmed.length <= 14) {
|
||||
return trimmed;
|
||||
}
|
||||
return `${trimmed.slice(0, 6)}...${trimmed.slice(-4)}`;
|
||||
}
|
||||
|
||||
@@ -63,7 +69,9 @@ export function resolveGroupSessionKey(ctx: MsgContext): GroupKeyResolution | nu
|
||||
from.includes(":group:") ||
|
||||
from.includes(":channel:") ||
|
||||
isWhatsAppGroupId;
|
||||
if (!looksLikeGroup) return null;
|
||||
if (!looksLikeGroup) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const providerHint = ctx.Provider?.trim().toLowerCase();
|
||||
|
||||
@@ -74,7 +82,9 @@ export function resolveGroupSessionKey(ctx: MsgContext): GroupKeyResolution | nu
|
||||
const provider = headIsSurface
|
||||
? head
|
||||
: (providerHint ?? (isWhatsAppGroupId ? "whatsapp" : undefined));
|
||||
if (!provider) return null;
|
||||
if (!provider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const second = parts[1]?.trim().toLowerCase();
|
||||
const secondIsKind = second === "group" || second === "channel";
|
||||
@@ -89,7 +99,9 @@ export function resolveGroupSessionKey(ctx: MsgContext): GroupKeyResolution | nu
|
||||
: parts.slice(1).join(":")
|
||||
: from;
|
||||
const finalId = id.trim().toLowerCase();
|
||||
if (!finalId) return null;
|
||||
if (!finalId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
key: `${provider}:${kind}:${finalId}`,
|
||||
|
||||
Reference in New Issue
Block a user