@openclaw/mattermost 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/channel-plugin-api-ClU67Wyc.mjs +1 -0
- package/dist/.setup/{channel-plugin-runtime-DJgVmmbD.mjs → channel-plugin-api-CuxSSPV8.mjs} +146 -130
- package/dist/.setup/{channel.runtime-Cl_09ZUI.mjs → channel.runtime-B3RvYLQi.mjs} +28 -34
- package/dist/.setup/{client-B_4C9q6z.mjs → client-CR-hGmGr.mjs} +11 -84
- package/dist/.setup/{interactions-LQ_rJSdf.mjs → interactions-D5hhyPam.mjs} +23 -36
- package/dist/.setup/{monitor-CmsQnrEk.mjs → monitor-Bw_pTSF8.mjs} +292 -400
- package/dist/.setup/{monitor-auth-rr4M-8gH.mjs → monitor-auth-BxpEUfvc.mjs} +5 -11
- package/dist/.setup/{normalize-Dli2PK7k.mjs → normalize-CNFRtT1O.mjs} +21 -7
- package/dist/.setup/secret-contract-api-Drz4m5pq.mjs +2 -0
- package/dist/.setup/{send-C_-GT5iF.mjs → send-BSae9PKV.mjs} +100 -198
- package/dist/.setup/{slash-state-DJN_cER0.mjs → slash-state-DpZH2wr6.mjs} +362 -409
- package/dist/.source-module-urls/8fb0cb1067b83fd2cf3f3ba0f7a23e627c27e8e3adf1a4ea18753ddb884ff71e.json +1 -0
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -2
- package/dist/doctor-contract-api.js +1 -2
- package/dist/gateway-auth-api.js +1 -2
- package/dist/policy-api.js +1 -2
- package/dist/runtime-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/setup-entry.js +2 -2
- package/dist/slash-route-api.js +1 -2
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +172 -0
- package/package.json +5 -5
- package/dist/.setup/channel-plugin-api-BKpd51G7.mjs +0 -3
- package/dist/.setup/secret-contract-api-BGz5_6WD.mjs +0 -3
- package/dist/channel-plugin-runtime.js +0 -2
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { asOptionalObjectRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
|
|
3
3
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
4
|
-
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates
|
|
5
|
-
import {
|
|
6
|
-
import { captureChannelReadAuthority, captureEffectAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
4
|
+
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
|
|
5
|
+
import { captureChannelReadAuthority, responseWithRelease } from "openclaw/plugin-sdk/fetch-runtime";
|
|
7
6
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
7
|
import { readProviderJsonResponse, redactProviderResponseErrorText } from "openclaw/plugin-sdk/provider-http";
|
|
9
8
|
import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
10
|
-
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
9
|
+
import { isTransientNetworkError, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
11
10
|
import { fetchWithSsrFGuard, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
12
11
|
import { z } from "zod";
|
|
13
12
|
//#region extensions/mattermost/src/mattermost/client.ts
|
|
@@ -83,7 +82,6 @@ function createMattermostClient(params) {
|
|
|
83
82
|
if (!baseUrl) throw new Error("Mattermost baseUrl is required");
|
|
84
83
|
const apiBaseUrl = `${baseUrl}/api/v4`;
|
|
85
84
|
const token = params.botToken.trim();
|
|
86
|
-
const requestTimeoutMs = resolveTimerTimeoutMs(params.timeoutMs, MATTERMOST_REQUEST_TIMEOUT_MS);
|
|
87
85
|
const assertSenderCurrent = params.assertRequestCurrent;
|
|
88
86
|
let postDispatchStarted = false;
|
|
89
87
|
const assertRequestCurrent = assertSenderCurrent ? () => {
|
|
@@ -98,14 +96,13 @@ function createMattermostClient(params) {
|
|
|
98
96
|
});
|
|
99
97
|
}
|
|
100
98
|
} : void 0;
|
|
101
|
-
const
|
|
102
|
-
const guardedFetchImpl = async (input, init) => {
|
|
99
|
+
const fetchImpl = async (input, init) => {
|
|
103
100
|
const assertReadAuthority = captureChannelReadAuthority();
|
|
104
101
|
assertReadAuthority?.();
|
|
105
102
|
assertRequestCurrent?.();
|
|
106
103
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
107
104
|
const { timeoutMs: initTimeoutMs, isMessagePost, ...requestInit } = init ?? {};
|
|
108
|
-
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs,
|
|
105
|
+
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, MATTERMOST_REQUEST_TIMEOUT_MS);
|
|
109
106
|
const { response, release } = await fetchWithSsrFGuard({
|
|
110
107
|
url,
|
|
111
108
|
init: requestInit,
|
|
@@ -121,37 +118,6 @@ function createMattermostClient(params) {
|
|
|
121
118
|
});
|
|
122
119
|
return responseWithRelease(response, release);
|
|
123
120
|
};
|
|
124
|
-
const fetchImpl = (externalFetchImpl ? async (input, init) => {
|
|
125
|
-
const effect = captureEffectAuthority();
|
|
126
|
-
const assertReadAuthority = captureChannelReadAuthority();
|
|
127
|
-
assertReadAuthority?.();
|
|
128
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
129
|
-
const { timeoutMs: initTimeoutMs, isMessagePost, ...requestInit } = init ?? {};
|
|
130
|
-
const timeoutMs = resolveTimerTimeoutMs(initTimeoutMs, requestTimeoutMs);
|
|
131
|
-
const { signal: timeoutSignal, cleanup } = buildTimeoutAbortSignal({
|
|
132
|
-
timeoutMs,
|
|
133
|
-
operation: "mattermost-api",
|
|
134
|
-
url
|
|
135
|
-
});
|
|
136
|
-
const callerSignal = requestInit.signal ?? void 0;
|
|
137
|
-
const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
|
|
138
|
-
try {
|
|
139
|
-
const response = await effect.initiate(() => {
|
|
140
|
-
assertReadAuthority?.();
|
|
141
|
-
assertRequestCurrent?.();
|
|
142
|
-
signal?.throwIfAborted();
|
|
143
|
-
if (isMessagePost) postDispatchStarted = true;
|
|
144
|
-
return externalFetchImpl(input, {
|
|
145
|
-
...requestInit,
|
|
146
|
-
signal
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
return responseWithRelease(response, async () => cleanup());
|
|
150
|
-
} catch (error) {
|
|
151
|
-
cleanup();
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
} : void 0) ?? guardedFetchImpl;
|
|
155
121
|
const request = async (path, init) => {
|
|
156
122
|
const url = buildMattermostApiUrl(baseUrl, path);
|
|
157
123
|
const { discardResponse, ...requestInit } = init ?? {};
|
|
@@ -238,31 +204,6 @@ async function sendMattermostTyping(client, params) {
|
|
|
238
204
|
discardResponse: true
|
|
239
205
|
});
|
|
240
206
|
}
|
|
241
|
-
const RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
242
|
-
"ECONNRESET",
|
|
243
|
-
"ECONNREFUSED",
|
|
244
|
-
"ETIMEDOUT",
|
|
245
|
-
"ESOCKETTIMEDOUT",
|
|
246
|
-
"ECONNABORTED",
|
|
247
|
-
"ENOTFOUND",
|
|
248
|
-
"EAI_AGAIN",
|
|
249
|
-
"EHOSTUNREACH",
|
|
250
|
-
"ENETUNREACH",
|
|
251
|
-
"EPIPE",
|
|
252
|
-
"UND_ERR_CONNECT_TIMEOUT",
|
|
253
|
-
"UND_ERR_DNS_RESOLVE_FAILED",
|
|
254
|
-
"UND_ERR_CONNECT",
|
|
255
|
-
"UND_ERR_SOCKET",
|
|
256
|
-
"UND_ERR_HEADERS_TIMEOUT",
|
|
257
|
-
"UND_ERR_BODY_TIMEOUT"
|
|
258
|
-
]);
|
|
259
|
-
const RETRYABLE_NETWORK_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
260
|
-
"AbortError",
|
|
261
|
-
"TimeoutError",
|
|
262
|
-
"ConnectTimeoutError",
|
|
263
|
-
"HeadersTimeoutError",
|
|
264
|
-
"BodyTimeoutError"
|
|
265
|
-
]);
|
|
266
207
|
const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
|
|
267
208
|
"network error",
|
|
268
209
|
"timeout",
|
|
@@ -284,17 +225,11 @@ const RETRYABLE_NETWORK_MESSAGE_SNIPPETS = [
|
|
|
284
225
|
async function createMattermostDirectChannelWithRetry(client, userIds, options = {}) {
|
|
285
226
|
const { maxRetries = 3, initialDelayMs = 1e3, maxDelayMs = 1e4, timeoutMs: rawTimeoutMs = 3e4, onRetry } = options;
|
|
286
227
|
const timeoutMs = resolveTimerTimeoutMs(rawTimeoutMs, 3e4);
|
|
287
|
-
return await retryAsync(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
timeoutMs
|
|
293
|
-
});
|
|
294
|
-
} catch (err) {
|
|
295
|
-
throw err instanceof Error ? err : new Error(String(err));
|
|
296
|
-
}
|
|
297
|
-
}, {
|
|
228
|
+
return await retryAsync(() => client.request("/channels/direct", {
|
|
229
|
+
method: "POST",
|
|
230
|
+
body: JSON.stringify(userIds),
|
|
231
|
+
timeoutMs
|
|
232
|
+
}), {
|
|
298
233
|
attempts: maxRetries + 1,
|
|
299
234
|
minDelayMs: Math.min(initialDelayMs, maxDelayMs),
|
|
300
235
|
maxDelayMs,
|
|
@@ -314,20 +249,12 @@ function isRetryableError(error) {
|
|
|
314
249
|
const status = parseMattermostApiStatus(candidate);
|
|
315
250
|
if (status !== void 0) return status === 429 || status >= 500 && status < 600;
|
|
316
251
|
}
|
|
317
|
-
if (
|
|
318
|
-
if (candidates.some((candidate) => RETRYABLE_NETWORK_ERROR_NAMES.has(readErrorName(candidate)))) return true;
|
|
252
|
+
if (isTransientNetworkError(error)) return true;
|
|
319
253
|
return candidates.some((candidate) => {
|
|
320
254
|
const message = normalizeLowercaseStringOrEmpty(readStringField(asOptionalObjectRecord(candidate), "message"));
|
|
321
255
|
return message.includes("too many requests") || RETRYABLE_NETWORK_MESSAGE_SNIPPETS.some((pattern) => message.includes(pattern));
|
|
322
256
|
});
|
|
323
257
|
}
|
|
324
|
-
function readErrorCode(error) {
|
|
325
|
-
if (!error || typeof error !== "object") return;
|
|
326
|
-
const { code, errno } = error;
|
|
327
|
-
const raw = typeof code === "string" && code.trim() ? code : errno;
|
|
328
|
-
if (typeof raw === "string" && raw.trim()) return raw.trim().toUpperCase();
|
|
329
|
-
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
330
|
-
}
|
|
331
258
|
async function createMattermostPost(client, params) {
|
|
332
259
|
const payload = {
|
|
333
260
|
channel_id: params.channelId,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
|
|
2
2
|
import { t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
3
3
|
import { r as resolveCallbackHost } from "./callback-host-Bu2cmtfI.mjs";
|
|
4
|
-
import { y as updateMattermostPost } from "./client-
|
|
5
|
-
import { E as resolveClientIp, O as sendHttpRequestRejection, S as readRequestBodyWithLimit, _ as isTrustedProxyAddress, g as isRequestBodyLimitError } from "./monitor-auth-
|
|
4
|
+
import { y as updateMattermostPost } from "./client-CR-hGmGr.mjs";
|
|
5
|
+
import { E as resolveClientIp, O as sendHttpRequestRejection, S as readRequestBodyWithLimit, _ as isTrustedProxyAddress, g as isRequestBodyLimitError } from "./monitor-auth-BxpEUfvc.mjs";
|
|
6
6
|
import { createHmac } from "node:crypto";
|
|
7
|
+
import { sendJsonWithoutCharset } from "openclaw/plugin-sdk/http-response-runtime";
|
|
7
8
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
8
9
|
import { normalizeOptionalString, normalizeStringifiedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { safeParseJson } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
11
|
+
import { requestBodyErrorToText } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
10
12
|
//#region src/gateway/gateway-http-route-contracts.ts
|
|
11
13
|
const GATEWAY_PROBE_ROUTES = /* @__PURE__ */ new Map([
|
|
12
14
|
["/health", "live"],
|
|
@@ -63,7 +65,6 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
63
65
|
const candidates = /* @__PURE__ */ new Set([normalizePathForSecurity(pathname)]);
|
|
64
66
|
let decoded = pathname;
|
|
65
67
|
let malformedEncoding = false;
|
|
66
|
-
let decodePasses = 0;
|
|
67
68
|
for (let pass = 0; pass < MAX_PATH_DECODE_PASSES; pass++) {
|
|
68
69
|
let nextDecoded;
|
|
69
70
|
try {
|
|
@@ -73,7 +74,6 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
73
74
|
break;
|
|
74
75
|
}
|
|
75
76
|
if (nextDecoded === decoded) break;
|
|
76
|
-
decodePasses += 1;
|
|
77
77
|
decoded = nextDecoded;
|
|
78
78
|
candidates.add(normalizePathForSecurity(decoded));
|
|
79
79
|
}
|
|
@@ -85,17 +85,15 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
87
|
candidates: [...candidates],
|
|
88
|
-
decodePasses,
|
|
89
88
|
decodePassLimitReached,
|
|
90
89
|
malformedEncoding
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
92
|
function canonicalizePathForSecurity(pathname) {
|
|
94
|
-
const { candidates,
|
|
93
|
+
const { candidates, decodePassLimitReached, malformedEncoding } = buildCanonicalPathCandidates(pathname);
|
|
95
94
|
return {
|
|
96
95
|
canonicalPath: candidates[candidates.length - 1] ?? "/",
|
|
97
96
|
candidates,
|
|
98
|
-
decodePasses,
|
|
99
97
|
decodePassLimitReached,
|
|
100
98
|
malformedEncoding,
|
|
101
99
|
rawNormalizedPath: normalizePathSeparators(normalizeLowercaseStringOrEmpty$1(pathname)) || "/"
|
|
@@ -270,11 +268,6 @@ function buildButtonProps(params) {
|
|
|
270
268
|
text: params.text
|
|
271
269
|
}) };
|
|
272
270
|
}
|
|
273
|
-
function sendInteractionResponse(res, statusCode, body) {
|
|
274
|
-
res.statusCode = statusCode;
|
|
275
|
-
res.setHeader("Content-Type", "application/json");
|
|
276
|
-
res.end(JSON.stringify(body));
|
|
277
|
-
}
|
|
278
271
|
function createMattermostInteractionHandler(params) {
|
|
279
272
|
const { client, accountId, log } = params;
|
|
280
273
|
const core = getMattermostRuntime();
|
|
@@ -285,10 +278,8 @@ function createMattermostInteractionHandler(params) {
|
|
|
285
278
|
}
|
|
286
279
|
return async (req, res) => {
|
|
287
280
|
if (req.method !== "POST") {
|
|
288
|
-
res.statusCode = 405;
|
|
289
281
|
res.setHeader("Allow", "POST");
|
|
290
|
-
res
|
|
291
|
-
res.end(JSON.stringify({ error: "Method Not Allowed" }));
|
|
282
|
+
sendJsonWithoutCharset(res, 405, { error: "Method Not Allowed" });
|
|
292
283
|
return;
|
|
293
284
|
}
|
|
294
285
|
if (!isAllowedInteractionSource({
|
|
@@ -298,7 +289,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
298
289
|
allowRealIpFallback: params.allowRealIpFallback
|
|
299
290
|
})) {
|
|
300
291
|
log?.(`mattermost interaction: rejected callback source remote=${req.socket?.remoteAddress ?? "?"}`);
|
|
301
|
-
|
|
292
|
+
sendJsonWithoutCharset(res, 403, { error: "Forbidden origin" });
|
|
302
293
|
return;
|
|
303
294
|
}
|
|
304
295
|
let payload;
|
|
@@ -310,43 +301,39 @@ function createMattermostInteractionHandler(params) {
|
|
|
310
301
|
}));
|
|
311
302
|
} catch (err) {
|
|
312
303
|
log?.(`mattermost interaction: failed to parse body: ${String(err)}`);
|
|
313
|
-
if (isRequestBodyLimitError(err, "PAYLOAD_TOO_LARGE")) {
|
|
314
|
-
await sendHttpRequestRejection(req, res,
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if (isRequestBodyLimitError(err, "REQUEST_BODY_TIMEOUT")) {
|
|
318
|
-
await sendHttpRequestRejection(req, res, 408, JSON.stringify({ error: "Request body timeout" }), "application/json");
|
|
304
|
+
if (isRequestBodyLimitError(err, "PAYLOAD_TOO_LARGE") || isRequestBodyLimitError(err, "REQUEST_BODY_TIMEOUT")) {
|
|
305
|
+
await sendHttpRequestRejection(req, res, err.statusCode, JSON.stringify({ error: requestBodyErrorToText(err.code) }), "application/json");
|
|
319
306
|
return;
|
|
320
307
|
}
|
|
321
|
-
|
|
308
|
+
sendJsonWithoutCharset(res, 400, { error: "Invalid request body" });
|
|
322
309
|
return;
|
|
323
310
|
}
|
|
324
311
|
const context = payload.context;
|
|
325
312
|
if (!context) {
|
|
326
|
-
|
|
313
|
+
sendJsonWithoutCharset(res, 400, { error: "Missing context" });
|
|
327
314
|
return;
|
|
328
315
|
}
|
|
329
316
|
const token = context["_token"];
|
|
330
317
|
if (typeof token !== "string") {
|
|
331
318
|
log?.("mattermost interaction: missing _token in context");
|
|
332
|
-
|
|
319
|
+
sendJsonWithoutCharset(res, 403, { error: "Missing token" });
|
|
333
320
|
return;
|
|
334
321
|
}
|
|
335
322
|
const { _token, ...contextWithoutToken } = context;
|
|
336
323
|
if (!safeEqualSecret(generateInteractionToken(contextWithoutToken, accountId), token)) {
|
|
337
324
|
log?.("mattermost interaction: invalid _token");
|
|
338
|
-
|
|
325
|
+
sendJsonWithoutCharset(res, 403, { error: "Invalid token" });
|
|
339
326
|
return;
|
|
340
327
|
}
|
|
341
328
|
const actionId = context.action_id;
|
|
342
329
|
if (typeof actionId !== "string") {
|
|
343
|
-
|
|
330
|
+
sendJsonWithoutCharset(res, 400, { error: "Missing action_id in context" });
|
|
344
331
|
return;
|
|
345
332
|
}
|
|
346
333
|
const signedChannelId = typeof contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY] === "string" ? contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY].trim() : "";
|
|
347
334
|
if (signedChannelId && signedChannelId !== payload.channel_id) {
|
|
348
335
|
log?.(`mattermost interaction: signed channel mismatch payload=${payload.channel_id} signed=${signedChannelId}`);
|
|
349
|
-
|
|
336
|
+
sendJsonWithoutCharset(res, 403, { error: "Channel mismatch" });
|
|
350
337
|
return;
|
|
351
338
|
}
|
|
352
339
|
const userName = payload.user_name ?? payload.user_id;
|
|
@@ -358,7 +345,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
358
345
|
const postChannelId = originalPost.channel_id?.trim();
|
|
359
346
|
if (!postChannelId || postChannelId !== payload.channel_id) {
|
|
360
347
|
log?.(`mattermost interaction: post channel mismatch payload=${payload.channel_id} post=${postChannelId ?? "<missing>"}`);
|
|
361
|
-
|
|
348
|
+
sendJsonWithoutCharset(res, 403, { error: "Post/channel mismatch" });
|
|
362
349
|
return;
|
|
363
350
|
}
|
|
364
351
|
originalMessage = originalPost.message ?? "";
|
|
@@ -372,12 +359,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
372
359
|
}
|
|
373
360
|
if (clickedButtonName === null) {
|
|
374
361
|
log?.(`mattermost interaction: action ${actionId} not found in post ${payload.post_id}`);
|
|
375
|
-
|
|
362
|
+
sendJsonWithoutCharset(res, 403, { error: "Unknown action" });
|
|
376
363
|
return;
|
|
377
364
|
}
|
|
378
365
|
} catch (err) {
|
|
379
366
|
log?.(`mattermost interaction: failed to validate post ${payload.post_id}: ${String(err)}`);
|
|
380
|
-
|
|
367
|
+
sendJsonWithoutCharset(res, 500, { error: "Failed to validate interaction" });
|
|
381
368
|
return;
|
|
382
369
|
}
|
|
383
370
|
log?.(`mattermost interaction: action=${actionId} user=${payload.user_name ?? payload.user_id} post=${payload.post_id} channel=${payload.channel_id}`);
|
|
@@ -387,12 +374,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
387
374
|
post: originalPost
|
|
388
375
|
});
|
|
389
376
|
if (!authorization.ok) {
|
|
390
|
-
|
|
377
|
+
sendJsonWithoutCharset(res, authorization.statusCode ?? 200, authorization.response ?? { ephemeral_text: "You are not allowed to use this action here." });
|
|
391
378
|
return;
|
|
392
379
|
}
|
|
393
380
|
} catch (err) {
|
|
394
381
|
log?.(`mattermost interaction: authorization failed: ${String(err)}`);
|
|
395
|
-
|
|
382
|
+
sendJsonWithoutCharset(res, 500, { error: "Interaction authorization failed" });
|
|
396
383
|
return;
|
|
397
384
|
}
|
|
398
385
|
if (params.handleInteraction) try {
|
|
@@ -406,12 +393,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
406
393
|
post: originalPost
|
|
407
394
|
});
|
|
408
395
|
if (response !== null) {
|
|
409
|
-
|
|
396
|
+
sendJsonWithoutCharset(res, 200, response);
|
|
410
397
|
return;
|
|
411
398
|
}
|
|
412
399
|
} catch (err) {
|
|
413
400
|
log?.(`mattermost interaction: custom handler failed: ${String(err)}`);
|
|
414
|
-
|
|
401
|
+
sendJsonWithoutCharset(res, 500, { error: "Interaction handler failed" });
|
|
415
402
|
return;
|
|
416
403
|
}
|
|
417
404
|
try {
|
|
@@ -436,7 +423,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
436
423
|
} catch (err) {
|
|
437
424
|
log?.(`mattermost interaction: failed to update post ${payload.post_id}: ${String(err)}`);
|
|
438
425
|
}
|
|
439
|
-
|
|
426
|
+
sendJsonWithoutCharset(res, 200, {});
|
|
440
427
|
if (params.dispatchButtonClick) try {
|
|
441
428
|
await params.dispatchButtonClick({
|
|
442
429
|
channelId: payload.channel_id,
|