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:
parent
352227f435
commit
44b27d1ba0
@ -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
|
||||||
|
|||||||
@ -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 & {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user