refactor(ringcentral): skip DM policy checks in selfOnly mode

In selfOnly mode, dmPolicy/allowFrom/groupPolicy settings are now
completely ignored since the owner is always allowed. This simplifies
the logic and avoids confusion.

Updated README to clarify which settings apply in selfOnly mode.

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:20:47 +08:00
parent 857408d78d
commit f77aeeb34c
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View File

@ -78,6 +78,10 @@ export RINGCENTRAL_JWT="your-jwt-token"
| `allowOtherChats` | boolean | `false` | In selfOnly mode, allow chats other than Personal |
| `name` | string | - | Bot display name |
| `textChunkLimit` | number | `4000` | Maximum characters per message chunk |
| `dmPolicy` | string | `"pairing"` | DM policy (only applies when `selfOnly: false`) |
| `groupPolicy` | string | `"allowlist"` | Group policy (only applies 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.
## Usage

View File

@ -330,17 +330,15 @@ async function processMessageWithPipeline(params: {
}
}
if (!isGroup) {
// DM policy checks - skip entirely in selfOnly mode (owner is always allowed)
if (!isGroup && !selfOnly) {
const dmEnabled = account.config.dm?.enabled !== false;
if (dmPolicy === "disabled" || !dmEnabled) {
logVerbose(core, runtime, `Blocked RingCentral DM from ${senderId} (dmPolicy=disabled)`);
return;
}
// In selfOnly mode, always allow the owner
const isOwner = selfOnly && ownerId && senderId === ownerId;
if (dmPolicy !== "open" && !isOwner) {
if (dmPolicy !== "open") {
const allowed = senderAllowedForCommands;
if (!allowed) {
if (dmPolicy === "pairing") {