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:
parent
857408d78d
commit
f77aeeb34c
@ -78,6 +78,10 @@ export RINGCENTRAL_JWT="your-jwt-token"
|
|||||||
| `allowOtherChats` | boolean | `false` | In selfOnly mode, allow chats other than Personal |
|
| `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`) |
|
||||||
|
| `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
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
const dmEnabled = account.config.dm?.enabled !== false;
|
||||||
if (dmPolicy === "disabled" || !dmEnabled) {
|
if (dmPolicy === "disabled" || !dmEnabled) {
|
||||||
logVerbose(core, runtime, `Blocked RingCentral DM from ${senderId} (dmPolicy=disabled)`);
|
logVerbose(core, runtime, `Blocked RingCentral DM from ${senderId} (dmPolicy=disabled)`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In selfOnly mode, always allow the owner
|
if (dmPolicy !== "open") {
|
||||||
const isOwner = selfOnly && ownerId && senderId === ownerId;
|
|
||||||
|
|
||||||
if (dmPolicy !== "open" && !isOwner) {
|
|
||||||
const allowed = senderAllowedForCommands;
|
const allowed = senderAllowedForCommands;
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
if (dmPolicy === "pairing") {
|
if (dmPolicy === "pairing") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user