From 44b27d1ba06c73739b528b8db55b333256a81777 Mon Sep 17 00:00:00 2001 From: John Lin Date: Tue, 27 Jan 2026 17:50:40 +0800 Subject: [PATCH] feat(ringcentral): add selfOnly mode for JWT authentication In JWT mode, bot uses the JWT user's identity. By default (selfOnly=true), only messages from the JWT user are processed, creating a self-conversation with the AI assistant. Set selfOnly=false to allow other users (requires allowFrom configuration). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- extensions/ringcentral/src/monitor.ts | 13 +++++++++---- extensions/ringcentral/src/types.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/ringcentral/src/monitor.ts b/extensions/ringcentral/src/monitor.ts index c1320e0fb..3b54cddd6 100644 --- a/extensions/ringcentral/src/monitor.ts +++ b/extensions/ringcentral/src/monitor.ts @@ -162,10 +162,15 @@ async function processMessageWithPipeline(params: { const rawBody = messageText || (hasMedia ? "" : ""); if (!rawBody) return; - // Skip messages from self (bot) - if (ownerId && senderId === ownerId) { - logVerbose(core, runtime, "skip self-authored message"); - return; + // In JWT mode (selfOnly), only accept messages from the JWT user themselves + // This is because the bot uses the JWT user's identity, so we're essentially + // having a conversation with ourselves (the AI assistant) + const selfOnly = account.config.selfOnly !== false; // default true + if (selfOnly && ownerId) { + if (senderId !== ownerId) { + logVerbose(core, runtime, `ignore message from non-owner: ${senderId} (selfOnly mode)`); + return; + } } // Fetch chat info to determine type diff --git a/extensions/ringcentral/src/types.ts b/extensions/ringcentral/src/types.ts index c870a3c0d..adf017997 100644 --- a/extensions/ringcentral/src/types.ts +++ b/extensions/ringcentral/src/types.ts @@ -115,6 +115,7 @@ export type RingCentralAccountConfig = { allowBots?: boolean; botExtensionId?: string; replyToMode?: "off" | "all"; + selfOnly?: boolean; // JWT mode: only accept messages from the JWT user (default: true) }; export type RingCentralConfig = RingCentralAccountConfig & {