refactor(ringcentral): simplify selfOnly mode, remove allowOtherChats

- selfOnly: true (default) = only respond to JWT user in Personal chat
- selfOnly: false = enable full DM/group policy controls

Removed redundant allowOtherChats option.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
John Lin 2026-01-28 10:23:59 +08:00
parent f77aeeb34c
commit 7e57e324d1
No known key found for this signature in database
4 changed files with 9 additions and 16 deletions

View File

@ -74,14 +74,13 @@ export RINGCENTRAL_JWT="your-jwt-token"
| `clientSecret` | string | - | RingCentral app client secret | | `clientSecret` | string | - | RingCentral app client secret |
| `jwt` | string | - | JWT token for authentication | | `jwt` | string | - | JWT token for authentication |
| `server` | string | `https://platform.ringcentral.com` | RingCentral API server URL | | `server` | string | `https://platform.ringcentral.com` | RingCentral API server URL |
| `selfOnly` | boolean | `true` | Only accept messages from the JWT user | | `selfOnly` | boolean | `true` | Only respond to JWT user in Personal chat |
| `allowOtherChats` | boolean | `false` | In selfOnly mode, allow chats other than Personal |
| `name` | string | - | Bot display name | | `name` | string | - | Bot display name |
| `textChunkLimit` | number | `4000` | Maximum characters per message chunk | | `textChunkLimit` | number | `4000` | Maximum characters per message chunk |
| `dmPolicy` | string | `"pairing"` | DM policy (only applies when `selfOnly: false`) | | `dmPolicy` | string | `"pairing"` | DM policy (only when `selfOnly: false`) |
| `groupPolicy` | string | `"allowlist"` | Group policy (only applies when `selfOnly: false`) | | `groupPolicy` | string | `"allowlist"` | Group policy (only when `selfOnly: false`) |
> **Note:** When `selfOnly: true` (default), the `dmPolicy`, `allowFrom`, `groupPolicy`, and related settings are ignored. The bot only responds to the JWT user in their Personal chat. > **Note:** When `selfOnly: true` (default), the bot only responds to the JWT user in their Personal chat. All other policy settings (`dmPolicy`, `allowFrom`, `groupPolicy`, etc.) are ignored.
## Usage ## Usage

View File

@ -44,7 +44,6 @@ const RingCentralAccountSchemaBase = z
allowBots: z.boolean().optional(), allowBots: z.boolean().optional(),
botExtensionId: z.string().optional(), botExtensionId: z.string().optional(),
selfOnly: z.boolean().optional(), selfOnly: z.boolean().optional(),
allowOtherChats: z.boolean().optional(),
}) })
.strict(); .strict();

View File

@ -226,14 +226,10 @@ async function processMessageWithPipeline(params: {
const isGroup = chatType !== "Direct" && chatType !== "PersonalChat" && chatType !== "Personal"; const isGroup = chatType !== "Direct" && chatType !== "PersonalChat" && chatType !== "Personal";
runtime.log?.(`[${account.accountId}] Chat type: ${chatType}, isGroup: ${isGroup}`); runtime.log?.(`[${account.accountId}] Chat type: ${chatType}, isGroup: ${isGroup}`);
// In selfOnly mode, by default only allow "Personal" chat (conversation with yourself) // In selfOnly mode, only allow "Personal" chat (conversation with yourself)
// Set allowOtherChats: true to allow DMs and groups if (selfOnly && !isPersonalChat) {
if (selfOnly) { logVerbose(core, runtime, `ignore non-personal chat in selfOnly mode: chatType=${chatType}`);
const allowOtherChats = account.config.allowOtherChats === true; // default false return;
if (!allowOtherChats && !isPersonalChat) {
logVerbose(core, runtime, `ignore non-personal chat in selfOnly mode: chatType=${chatType}`);
return;
}
} }
const defaultGroupPolicy = config.channels?.defaults?.groupPolicy; const defaultGroupPolicy = config.channels?.defaults?.groupPolicy;

View File

@ -114,8 +114,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) selfOnly?: boolean; // JWT mode: only accept messages from the JWT user in Personal chat (default: true)
allowOtherChats?: boolean; // In selfOnly mode, allow chats other than Personal (default: false)
}; };
export type RingCentralConfig = RingCentralAccountConfig & { export type RingCentralConfig = RingCentralAccountConfig & {