refactor(ringcentral): remove obsolete webhook-related code

Removed webhook configuration and API methods since WebSocket is now used:
- Remove webhookPath and webhookVerificationToken from config/types
- Remove createRingCentralWebhookSubscription/deleteRingCentralWebhookSubscription APIs
- Remove resolveRingCentralWebhookPath helper
- Update blurb to say 'WebSocket' instead of 'webhooks'
- Fix dmPolicy default to 'allowlist' in buildAccountSnapshot

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:35:52 +08:00
parent fac7419ca0
commit dba1763c81
No known key found for this signature in database
5 changed files with 4 additions and 58 deletions

View File

@ -163,41 +163,6 @@ export async function downloadRingCentralAttachment(params: {
};
}
export async function createRingCentralWebhookSubscription(params: {
account: ResolvedRingCentralAccount;
webhookUrl: string;
eventFilters: string[];
expiresIn?: number;
}): Promise<{ subscriptionId?: string; expiresIn?: number }> {
const { account, webhookUrl, eventFilters, expiresIn = 604799 } = params;
const platform = await getRingCentralPlatform(account);
const body = {
eventFilters,
deliveryMode: {
transportType: "WebHook",
address: webhookUrl,
},
expiresIn,
};
const response = await platform.post("/restapi/v1.0/subscription", body);
const result = (await response.json()) as { id?: string; expiresIn?: number };
return {
subscriptionId: result.id,
expiresIn: result.expiresIn,
};
}
export async function deleteRingCentralWebhookSubscription(params: {
account: ResolvedRingCentralAccount;
subscriptionId: string;
}): Promise<void> {
const { account, subscriptionId } = params;
const platform = await getRingCentralPlatform(account);
await platform.delete(`/restapi/v1.0/subscription/${subscriptionId}`);
}
export async function probeRingCentral(
account: ResolvedRingCentralAccount,
): Promise<{ ok: boolean; error?: string; elapsedMs: number }> {

View File

@ -29,7 +29,7 @@ import {
probeRingCentral,
} from "./api.js";
import { getRingCentralRuntime } from "./runtime.js";
import { resolveRingCentralWebhookPath, startRingCentralMonitor } from "./monitor.js";
import { startRingCentralMonitor } from "./monitor.js";
import {
normalizeRingCentralTarget,
isRingCentralChatTarget,
@ -90,7 +90,7 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
...meta,
label: "RingCentral",
selectionLabel: "RingCentral Team Messaging",
blurb: "RingCentral Team Messaging via REST API and webhooks.",
blurb: "RingCentral Team Messaging via REST API and WebSocket.",
order: 56,
},
pairing: {
@ -149,8 +149,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
"clientSecret",
"jwt",
"server",
"webhookPath",
"webhookVerificationToken",
"name",
],
}),
@ -328,11 +326,9 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
...(input.jwt ? { jwt: input.jwt } : {}),
};
const server = input.server?.trim();
const webhookPath = input.webhookPath?.trim();
const configPatch = {
...patch,
...(server ? { server } : {}),
...(webhookPath ? { webhookPath } : {}),
};
if (accountId === DEFAULT_ACCOUNT_ID) {
return {
@ -495,7 +491,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
configured: snapshot.configured ?? false,
credentialSource: snapshot.credentialSource ?? "none",
server: snapshot.server ?? null,
webhookPath: snapshot.webhookPath ?? null,
running: snapshot.running ?? false,
lastStartAt: snapshot.lastStartAt ?? null,
lastStopAt: snapshot.lastStopAt ?? null,
@ -512,26 +507,24 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
credentialSource: account.credentialSource,
server: account.server,
clientId: account.clientId ? `${account.clientId.slice(0, 8)}...` : undefined,
webhookPath: account.config.webhookPath,
running: runtime?.running ?? false,
lastStartAt: runtime?.lastStartAt ?? null,
lastStopAt: runtime?.lastStopAt ?? null,
lastError: runtime?.lastError ?? null,
lastInboundAt: runtime?.lastInboundAt ?? null,
lastOutboundAt: runtime?.lastOutboundAt ?? null,
dmPolicy: account.config.dm?.policy ?? "pairing",
dmPolicy: account.config.dm?.policy ?? "allowlist",
probe,
}),
},
gateway: {
startAccount: async (ctx) => {
const account = ctx.account;
ctx.log?.info(`[${account.accountId}] starting RingCentral webhook`);
ctx.log?.info(`[${account.accountId}] starting RingCentral WebSocket`);
ctx.setStatus({
accountId: account.accountId,
running: true,
lastStartAt: Date.now(),
webhookPath: resolveRingCentralWebhookPath({ account }),
server: account.server,
});
const unregister = await startRingCentralMonitor({
@ -539,7 +532,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
config: ctx.cfg as ClawdbotConfig,
runtime: ctx.runtime,
abortSignal: ctx.abortSignal,
webhookPath: account.config.webhookPath,
statusSink: (patch) => ctx.setStatus({ accountId: account.accountId, ...patch }),
});
return () => {

View File

@ -27,8 +27,6 @@ const RingCentralAccountSchemaBase = z
clientSecret: z.string().optional(),
jwt: z.string().optional(),
server: z.string().optional(),
webhookPath: z.string().optional(),
webhookVerificationToken: z.string().optional(),
markdown: MarkdownConfigSchema,
dmPolicy: DmPolicySchema.optional().default("allowlist"),
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),

View File

@ -739,10 +739,3 @@ export async function startRingCentralMonitor(
return cleanup;
}
// Keep the webhook path resolver for status display
export function resolveRingCentralWebhookPath(_params: {
account: ResolvedRingCentralAccount;
}): string {
return "(WebSocket)";
}

View File

@ -96,8 +96,6 @@ export type RingCentralAccountConfig = {
clientSecret?: string;
jwt?: string;
server?: string;
webhookPath?: string;
webhookVerificationToken?: string;
markdown?: MarkdownConfig;
dmPolicy?: DmPolicy;
allowFrom?: Array<string | number>;