fix: allow group activation for allowFrom senders

This commit is contained in:
Peter Steinberger
2026-01-05 02:33:51 +01:00
parent e4335ea094
commit 67420e9a81

View File

@@ -64,7 +64,7 @@ export function buildCommandContext(params: {
const from = (ctx.From ?? "").replace(/^whatsapp:/, ""); const from = (ctx.From ?? "").replace(/^whatsapp:/, "");
const to = (ctx.To ?? "").replace(/^whatsapp:/, ""); const to = (ctx.To ?? "").replace(/^whatsapp:/, "");
const allowFromList = const allowFromList =
configuredAllowFrom?.filter((entry) => entry && entry.trim()) ?? []; configuredAllowFrom?.filter((entry) => entry?.trim()) ?? [];
const allowAll = const allowAll =
!isWhatsAppSurface || !isWhatsAppSurface ||
allowFromList.length === 0 || allowFromList.length === 0 ||
@@ -163,18 +163,15 @@ export async function handleCommands(params: {
reply: { text: "⚙️ Group activation only applies to group chats." }, reply: { text: "⚙️ Group activation only applies to group chats." },
}; };
} }
const activationOwnerList = const activationOwnerList = command.ownerList;
command.ownerList.length > 0
? command.ownerList
: command.isWhatsAppSurface && command.to
? [normalizeE164(command.to)]
: [];
const activationSenderE164 = command.senderE164 const activationSenderE164 = command.senderE164
? normalizeE164(command.senderE164) ? normalizeE164(command.senderE164)
: ""; : "";
const isActivationOwner = const isActivationOwner =
Boolean(activationSenderE164) && !command.isWhatsAppSurface || activationOwnerList.length === 0
activationOwnerList.includes(activationSenderE164); ? command.isAuthorizedSender
: Boolean(activationSenderE164) &&
activationOwnerList.includes(activationSenderE164);
if ( if (
!command.isAuthorizedSender || !command.isAuthorizedSender ||