mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 19:06:52 +00:00
refactor(gateway): unify control-ui and plugin webhook routing
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
createScopedPairingAccess,
|
||||
createReplyPrefixOptions,
|
||||
readJsonBodyWithLimit,
|
||||
registerPluginHttpRoute,
|
||||
registerWebhookTarget,
|
||||
rejectNonPostWebhookRequest,
|
||||
isDangerousNameMatchingEnabled,
|
||||
@@ -100,7 +101,24 @@ function warnDeprecatedUsersEmailEntries(
|
||||
}
|
||||
|
||||
export function registerGoogleChatWebhookTarget(target: WebhookTarget): () => void {
|
||||
return registerWebhookTarget(webhookTargets, target).unregister;
|
||||
return registerWebhookTarget(webhookTargets, target, {
|
||||
onFirstPathTarget: ({ path }) =>
|
||||
registerPluginHttpRoute({
|
||||
path,
|
||||
pluginId: "googlechat",
|
||||
source: "googlechat-webhook",
|
||||
accountId: target.account.accountId,
|
||||
log: target.runtime.log,
|
||||
handler: async (req, res) => {
|
||||
const handled = await handleGoogleChatWebhookRequest(req, res);
|
||||
if (!handled && !res.headersSent) {
|
||||
res.statusCode = 404;
|
||||
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
res.end("Not Found");
|
||||
}
|
||||
},
|
||||
}),
|
||||
}).unregister;
|
||||
}
|
||||
|
||||
function normalizeAudienceType(value?: string | null): GoogleChatAudienceType | undefined {
|
||||
|
||||
Reference in New Issue
Block a user