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>
This commit is contained in:
John Lin 2026-01-27 17:50:40 +08:00
parent 352227f435
commit 44b27d1ba0
No known key found for this signature in database
2 changed files with 10 additions and 4 deletions

View File

@ -162,10 +162,15 @@ async function processMessageWithPipeline(params: {
const rawBody = messageText || (hasMedia ? "<media:attachment>" : ""); const rawBody = messageText || (hasMedia ? "<media:attachment>" : "");
if (!rawBody) return; if (!rawBody) return;
// Skip messages from self (bot) // In JWT mode (selfOnly), only accept messages from the JWT user themselves
if (ownerId && senderId === ownerId) { // This is because the bot uses the JWT user's identity, so we're essentially
logVerbose(core, runtime, "skip self-authored message"); // having a conversation with ourselves (the AI assistant)
return; 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 // Fetch chat info to determine type

View File

@ -115,6 +115,7 @@ export type RingCentralAccountConfig = {
allowBots?: boolean; allowBots?: boolean;
botExtensionId?: string; botExtensionId?: string;
replyToMode?: "off" | "all"; replyToMode?: "off" | "all";
selfOnly?: boolean; // JWT mode: only accept messages from the JWT user (default: true)
}; };
export type RingCentralConfig = RingCentralAccountConfig & { export type RingCentralConfig = RingCentralAccountConfig & {