refactor(gateway): unify control-ui and plugin webhook routing

This commit is contained in:
Peter Steinberger
2026-03-02 16:17:31 +00:00
parent 21708f58ce
commit b13d48987c
17 changed files with 870 additions and 425 deletions

View File

@@ -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 {