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:
parent
fac7419ca0
commit
dba1763c81
@ -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(
|
export async function probeRingCentral(
|
||||||
account: ResolvedRingCentralAccount,
|
account: ResolvedRingCentralAccount,
|
||||||
): Promise<{ ok: boolean; error?: string; elapsedMs: number }> {
|
): Promise<{ ok: boolean; error?: string; elapsedMs: number }> {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import {
|
|||||||
probeRingCentral,
|
probeRingCentral,
|
||||||
} from "./api.js";
|
} from "./api.js";
|
||||||
import { getRingCentralRuntime } from "./runtime.js";
|
import { getRingCentralRuntime } from "./runtime.js";
|
||||||
import { resolveRingCentralWebhookPath, startRingCentralMonitor } from "./monitor.js";
|
import { startRingCentralMonitor } from "./monitor.js";
|
||||||
import {
|
import {
|
||||||
normalizeRingCentralTarget,
|
normalizeRingCentralTarget,
|
||||||
isRingCentralChatTarget,
|
isRingCentralChatTarget,
|
||||||
@ -90,7 +90,7 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
...meta,
|
...meta,
|
||||||
label: "RingCentral",
|
label: "RingCentral",
|
||||||
selectionLabel: "RingCentral Team Messaging",
|
selectionLabel: "RingCentral Team Messaging",
|
||||||
blurb: "RingCentral Team Messaging via REST API and webhooks.",
|
blurb: "RingCentral Team Messaging via REST API and WebSocket.",
|
||||||
order: 56,
|
order: 56,
|
||||||
},
|
},
|
||||||
pairing: {
|
pairing: {
|
||||||
@ -149,8 +149,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
"clientSecret",
|
"clientSecret",
|
||||||
"jwt",
|
"jwt",
|
||||||
"server",
|
"server",
|
||||||
"webhookPath",
|
|
||||||
"webhookVerificationToken",
|
|
||||||
"name",
|
"name",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -328,11 +326,9 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
...(input.jwt ? { jwt: input.jwt } : {}),
|
...(input.jwt ? { jwt: input.jwt } : {}),
|
||||||
};
|
};
|
||||||
const server = input.server?.trim();
|
const server = input.server?.trim();
|
||||||
const webhookPath = input.webhookPath?.trim();
|
|
||||||
const configPatch = {
|
const configPatch = {
|
||||||
...patch,
|
...patch,
|
||||||
...(server ? { server } : {}),
|
...(server ? { server } : {}),
|
||||||
...(webhookPath ? { webhookPath } : {}),
|
|
||||||
};
|
};
|
||||||
if (accountId === DEFAULT_ACCOUNT_ID) {
|
if (accountId === DEFAULT_ACCOUNT_ID) {
|
||||||
return {
|
return {
|
||||||
@ -495,7 +491,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
configured: snapshot.configured ?? false,
|
configured: snapshot.configured ?? false,
|
||||||
credentialSource: snapshot.credentialSource ?? "none",
|
credentialSource: snapshot.credentialSource ?? "none",
|
||||||
server: snapshot.server ?? null,
|
server: snapshot.server ?? null,
|
||||||
webhookPath: snapshot.webhookPath ?? null,
|
|
||||||
running: snapshot.running ?? false,
|
running: snapshot.running ?? false,
|
||||||
lastStartAt: snapshot.lastStartAt ?? null,
|
lastStartAt: snapshot.lastStartAt ?? null,
|
||||||
lastStopAt: snapshot.lastStopAt ?? null,
|
lastStopAt: snapshot.lastStopAt ?? null,
|
||||||
@ -512,26 +507,24 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
credentialSource: account.credentialSource,
|
credentialSource: account.credentialSource,
|
||||||
server: account.server,
|
server: account.server,
|
||||||
clientId: account.clientId ? `${account.clientId.slice(0, 8)}...` : undefined,
|
clientId: account.clientId ? `${account.clientId.slice(0, 8)}...` : undefined,
|
||||||
webhookPath: account.config.webhookPath,
|
|
||||||
running: runtime?.running ?? false,
|
running: runtime?.running ?? false,
|
||||||
lastStartAt: runtime?.lastStartAt ?? null,
|
lastStartAt: runtime?.lastStartAt ?? null,
|
||||||
lastStopAt: runtime?.lastStopAt ?? null,
|
lastStopAt: runtime?.lastStopAt ?? null,
|
||||||
lastError: runtime?.lastError ?? null,
|
lastError: runtime?.lastError ?? null,
|
||||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
lastInboundAt: runtime?.lastInboundAt ?? null,
|
||||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
||||||
dmPolicy: account.config.dm?.policy ?? "pairing",
|
dmPolicy: account.config.dm?.policy ?? "allowlist",
|
||||||
probe,
|
probe,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
gateway: {
|
gateway: {
|
||||||
startAccount: async (ctx) => {
|
startAccount: async (ctx) => {
|
||||||
const account = ctx.account;
|
const account = ctx.account;
|
||||||
ctx.log?.info(`[${account.accountId}] starting RingCentral webhook`);
|
ctx.log?.info(`[${account.accountId}] starting RingCentral WebSocket`);
|
||||||
ctx.setStatus({
|
ctx.setStatus({
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
running: true,
|
running: true,
|
||||||
lastStartAt: Date.now(),
|
lastStartAt: Date.now(),
|
||||||
webhookPath: resolveRingCentralWebhookPath({ account }),
|
|
||||||
server: account.server,
|
server: account.server,
|
||||||
});
|
});
|
||||||
const unregister = await startRingCentralMonitor({
|
const unregister = await startRingCentralMonitor({
|
||||||
@ -539,7 +532,6 @@ export const ringcentralPlugin: ChannelPlugin<ResolvedRingCentralAccount> = {
|
|||||||
config: ctx.cfg as ClawdbotConfig,
|
config: ctx.cfg as ClawdbotConfig,
|
||||||
runtime: ctx.runtime,
|
runtime: ctx.runtime,
|
||||||
abortSignal: ctx.abortSignal,
|
abortSignal: ctx.abortSignal,
|
||||||
webhookPath: account.config.webhookPath,
|
|
||||||
statusSink: (patch) => ctx.setStatus({ accountId: account.accountId, ...patch }),
|
statusSink: (patch) => ctx.setStatus({ accountId: account.accountId, ...patch }),
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@ -27,8 +27,6 @@ const RingCentralAccountSchemaBase = z
|
|||||||
clientSecret: z.string().optional(),
|
clientSecret: z.string().optional(),
|
||||||
jwt: z.string().optional(),
|
jwt: z.string().optional(),
|
||||||
server: z.string().optional(),
|
server: z.string().optional(),
|
||||||
webhookPath: z.string().optional(),
|
|
||||||
webhookVerificationToken: z.string().optional(),
|
|
||||||
markdown: MarkdownConfigSchema,
|
markdown: MarkdownConfigSchema,
|
||||||
dmPolicy: DmPolicySchema.optional().default("allowlist"),
|
dmPolicy: DmPolicySchema.optional().default("allowlist"),
|
||||||
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||||
|
|||||||
@ -739,10 +739,3 @@ export async function startRingCentralMonitor(
|
|||||||
|
|
||||||
return cleanup;
|
return cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the webhook path resolver for status display
|
|
||||||
export function resolveRingCentralWebhookPath(_params: {
|
|
||||||
account: ResolvedRingCentralAccount;
|
|
||||||
}): string {
|
|
||||||
return "(WebSocket)";
|
|
||||||
}
|
|
||||||
|
|||||||
@ -96,8 +96,6 @@ export type RingCentralAccountConfig = {
|
|||||||
clientSecret?: string;
|
clientSecret?: string;
|
||||||
jwt?: string;
|
jwt?: string;
|
||||||
server?: string;
|
server?: string;
|
||||||
webhookPath?: string;
|
|
||||||
webhookVerificationToken?: string;
|
|
||||||
markdown?: MarkdownConfig;
|
markdown?: MarkdownConfig;
|
||||||
dmPolicy?: DmPolicy;
|
dmPolicy?: DmPolicy;
|
||||||
allowFrom?: Array<string | number>;
|
allowFrom?: Array<string | number>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user