@openclaw/mattermost 2026.10.10 → 2026.11.5-beta.1
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-C5kL5jd0.mjs +1 -0
- package/dist/.setup/{channel-plugin-runtime-CLBgUA35.mjs → channel-plugin-api-CC8EU4bs.mjs} +147 -130
- package/dist/.setup/{channel.runtime-BBMzxlPB.mjs → channel.runtime-ukouI9k4.mjs} +37 -37
- package/dist/.setup/{client-VHp4VYIf.mjs → client-CVipK0N2.mjs} +11 -84
- package/dist/.setup/{interactions-7eWssSf1.mjs → interactions-cgV9-piH.mjs} +23 -36
- package/dist/.setup/{monitor-agLGA4lV.mjs → monitor-Bn-I4iu7.mjs} +292 -398
- package/dist/.setup/{monitor-auth-0gZXtoHv.mjs → monitor-auth-D7Fl9CyF.mjs} +5 -11
- package/dist/.setup/{normalize-C_DYEHki.mjs → normalize-DuLSV4tT.mjs} +21 -7
- package/dist/.setup/secret-contract-BkDCURCE.mjs +19 -0
- package/dist/.setup/{secret-contract-api-CmBND3cW.mjs → secret-contract-api-DydsmAPQ.mjs} +1 -1
- package/dist/.setup/{send-3ye1gFt3.mjs → send-CoWXMKnY.mjs} +100 -198
- package/dist/.setup/{slash-state-V13EaHX9.mjs → slash-state-CwLVacYg.mjs} +361 -408
- package/dist/.source-module-urls/8fb0cb1067b83fd2cf3f3ba0f7a23e627c27e8e3adf1a4ea18753ddb884ff71e.json +1 -0
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +2 -2
- package/dist/slash-route-api.js +1 -1
- 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-Vq9imWd1.mjs +0 -2
- package/dist/.setup/secret-contract-H9g0kHHQ.mjs +0 -11
- package/dist/.source-module-urls/9b327bbbce22c2cbef393c115f9a63999afd57e223aad992389710cb3f1e29cc.json +0 -1
- package/dist/channel-plugin-runtime.js +0 -1
|
@@ -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
|
// 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-782esTHO.mjs";
|
|
2
2
|
import { t as getMattermostRuntime } from "./runtime-y_L8jPMH.mjs";
|
|
3
3
|
import { r as resolveCallbackHost } from "./callback-host-CRQTeNn9.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-CVipK0N2.mjs";
|
|
5
|
+
import { E as resolveClientIp, O as sendHttpRequestRejection, S as readRequestBodyWithLimit, _ as isTrustedProxyAddress, g as isRequestBodyLimitError } from "./monitor-auth-D7Fl9CyF.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
|
// src/gateway/gateway-http-route-contracts.ts
|
|
11
13
|
const GATEWAY_PROBE_ROUTES = /* @__PURE__ */ new Map([
|
|
12
14
|
["/health", "live"],
|
|
@@ -60,7 +62,6 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
60
62
|
const candidates = /* @__PURE__ */ new Set([normalizePathForSecurity(pathname)]);
|
|
61
63
|
let decoded = pathname;
|
|
62
64
|
let malformedEncoding = false;
|
|
63
|
-
let decodePasses = 0;
|
|
64
65
|
for (let pass = 0; pass < MAX_PATH_DECODE_PASSES; pass++) {
|
|
65
66
|
let nextDecoded;
|
|
66
67
|
try {
|
|
@@ -70,7 +71,6 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
70
71
|
break;
|
|
71
72
|
}
|
|
72
73
|
if (nextDecoded === decoded) break;
|
|
73
|
-
decodePasses += 1;
|
|
74
74
|
decoded = nextDecoded;
|
|
75
75
|
candidates.add(normalizePathForSecurity(decoded));
|
|
76
76
|
}
|
|
@@ -82,17 +82,15 @@ function buildCanonicalPathCandidates(pathname) {
|
|
|
82
82
|
}
|
|
83
83
|
return {
|
|
84
84
|
candidates: [...candidates],
|
|
85
|
-
decodePasses,
|
|
86
85
|
decodePassLimitReached,
|
|
87
86
|
malformedEncoding
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
function canonicalizePathForSecurity(pathname) {
|
|
91
|
-
const { candidates,
|
|
90
|
+
const { candidates, decodePassLimitReached, malformedEncoding } = buildCanonicalPathCandidates(pathname);
|
|
92
91
|
return {
|
|
93
92
|
canonicalPath: candidates[candidates.length - 1] ?? "/",
|
|
94
93
|
candidates,
|
|
95
|
-
decodePasses,
|
|
96
94
|
decodePassLimitReached,
|
|
97
95
|
malformedEncoding,
|
|
98
96
|
rawNormalizedPath: normalizePathSeparators(normalizeLowercaseStringOrEmpty$1(pathname)) || "/"
|
|
@@ -264,11 +262,6 @@ function buildButtonProps(params) {
|
|
|
264
262
|
text: params.text
|
|
265
263
|
}) };
|
|
266
264
|
}
|
|
267
|
-
function sendInteractionResponse(res, statusCode, body) {
|
|
268
|
-
res.statusCode = statusCode;
|
|
269
|
-
res.setHeader("Content-Type", "application/json");
|
|
270
|
-
res.end(JSON.stringify(body));
|
|
271
|
-
}
|
|
272
265
|
function createMattermostInteractionHandler(params) {
|
|
273
266
|
const { client, accountId, log } = params;
|
|
274
267
|
const core = getMattermostRuntime();
|
|
@@ -279,10 +272,8 @@ function createMattermostInteractionHandler(params) {
|
|
|
279
272
|
}
|
|
280
273
|
return async (req, res) => {
|
|
281
274
|
if (req.method !== "POST") {
|
|
282
|
-
res.statusCode = 405;
|
|
283
275
|
res.setHeader("Allow", "POST");
|
|
284
|
-
res
|
|
285
|
-
res.end(JSON.stringify({ error: "Method Not Allowed" }));
|
|
276
|
+
sendJsonWithoutCharset(res, 405, { error: "Method Not Allowed" });
|
|
286
277
|
return;
|
|
287
278
|
}
|
|
288
279
|
if (!isAllowedInteractionSource({
|
|
@@ -292,7 +283,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
292
283
|
allowRealIpFallback: params.allowRealIpFallback
|
|
293
284
|
})) {
|
|
294
285
|
log?.(`mattermost interaction: rejected callback source remote=${req.socket?.remoteAddress ?? "?"}`);
|
|
295
|
-
|
|
286
|
+
sendJsonWithoutCharset(res, 403, { error: "Forbidden origin" });
|
|
296
287
|
return;
|
|
297
288
|
}
|
|
298
289
|
let payload;
|
|
@@ -304,43 +295,39 @@ function createMattermostInteractionHandler(params) {
|
|
|
304
295
|
}));
|
|
305
296
|
} catch (err) {
|
|
306
297
|
log?.(`mattermost interaction: failed to parse body: ${String(err)}`);
|
|
307
|
-
if (isRequestBodyLimitError(err, "PAYLOAD_TOO_LARGE")) {
|
|
308
|
-
await sendHttpRequestRejection(req, res,
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (isRequestBodyLimitError(err, "REQUEST_BODY_TIMEOUT")) {
|
|
312
|
-
await sendHttpRequestRejection(req, res, 408, JSON.stringify({ error: "Request body timeout" }), "application/json");
|
|
298
|
+
if (isRequestBodyLimitError(err, "PAYLOAD_TOO_LARGE") || isRequestBodyLimitError(err, "REQUEST_BODY_TIMEOUT")) {
|
|
299
|
+
await sendHttpRequestRejection(req, res, err.statusCode, JSON.stringify({ error: requestBodyErrorToText(err.code) }), "application/json");
|
|
313
300
|
return;
|
|
314
301
|
}
|
|
315
|
-
|
|
302
|
+
sendJsonWithoutCharset(res, 400, { error: "Invalid request body" });
|
|
316
303
|
return;
|
|
317
304
|
}
|
|
318
305
|
const context = payload.context;
|
|
319
306
|
if (!context) {
|
|
320
|
-
|
|
307
|
+
sendJsonWithoutCharset(res, 400, { error: "Missing context" });
|
|
321
308
|
return;
|
|
322
309
|
}
|
|
323
310
|
const token = context["_token"];
|
|
324
311
|
if (typeof token !== "string") {
|
|
325
312
|
log?.("mattermost interaction: missing _token in context");
|
|
326
|
-
|
|
313
|
+
sendJsonWithoutCharset(res, 403, { error: "Missing token" });
|
|
327
314
|
return;
|
|
328
315
|
}
|
|
329
316
|
const { _token, ...contextWithoutToken } = context;
|
|
330
317
|
if (!safeEqualSecret(generateInteractionToken(contextWithoutToken, accountId), token)) {
|
|
331
318
|
log?.("mattermost interaction: invalid _token");
|
|
332
|
-
|
|
319
|
+
sendJsonWithoutCharset(res, 403, { error: "Invalid token" });
|
|
333
320
|
return;
|
|
334
321
|
}
|
|
335
322
|
const actionId = context.action_id;
|
|
336
323
|
if (typeof actionId !== "string") {
|
|
337
|
-
|
|
324
|
+
sendJsonWithoutCharset(res, 400, { error: "Missing action_id in context" });
|
|
338
325
|
return;
|
|
339
326
|
}
|
|
340
327
|
const signedChannelId = typeof contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY] === "string" ? contextWithoutToken[SIGNED_CHANNEL_ID_CONTEXT_KEY].trim() : "";
|
|
341
328
|
if (signedChannelId && signedChannelId !== payload.channel_id) {
|
|
342
329
|
log?.(`mattermost interaction: signed channel mismatch payload=${payload.channel_id} signed=${signedChannelId}`);
|
|
343
|
-
|
|
330
|
+
sendJsonWithoutCharset(res, 403, { error: "Channel mismatch" });
|
|
344
331
|
return;
|
|
345
332
|
}
|
|
346
333
|
const userName = payload.user_name ?? payload.user_id;
|
|
@@ -352,7 +339,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
352
339
|
const postChannelId = originalPost.channel_id?.trim();
|
|
353
340
|
if (!postChannelId || postChannelId !== payload.channel_id) {
|
|
354
341
|
log?.(`mattermost interaction: post channel mismatch payload=${payload.channel_id} post=${postChannelId ?? "<missing>"}`);
|
|
355
|
-
|
|
342
|
+
sendJsonWithoutCharset(res, 403, { error: "Post/channel mismatch" });
|
|
356
343
|
return;
|
|
357
344
|
}
|
|
358
345
|
originalMessage = originalPost.message ?? "";
|
|
@@ -366,12 +353,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
366
353
|
}
|
|
367
354
|
if (clickedButtonName === null) {
|
|
368
355
|
log?.(`mattermost interaction: action ${actionId} not found in post ${payload.post_id}`);
|
|
369
|
-
|
|
356
|
+
sendJsonWithoutCharset(res, 403, { error: "Unknown action" });
|
|
370
357
|
return;
|
|
371
358
|
}
|
|
372
359
|
} catch (err) {
|
|
373
360
|
log?.(`mattermost interaction: failed to validate post ${payload.post_id}: ${String(err)}`);
|
|
374
|
-
|
|
361
|
+
sendJsonWithoutCharset(res, 500, { error: "Failed to validate interaction" });
|
|
375
362
|
return;
|
|
376
363
|
}
|
|
377
364
|
log?.(`mattermost interaction: action=${actionId} user=${payload.user_name ?? payload.user_id} post=${payload.post_id} channel=${payload.channel_id}`);
|
|
@@ -381,12 +368,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
381
368
|
post: originalPost
|
|
382
369
|
});
|
|
383
370
|
if (!authorization.ok) {
|
|
384
|
-
|
|
371
|
+
sendJsonWithoutCharset(res, authorization.statusCode ?? 200, authorization.response ?? { ephemeral_text: "You are not allowed to use this action here." });
|
|
385
372
|
return;
|
|
386
373
|
}
|
|
387
374
|
} catch (err) {
|
|
388
375
|
log?.(`mattermost interaction: authorization failed: ${String(err)}`);
|
|
389
|
-
|
|
376
|
+
sendJsonWithoutCharset(res, 500, { error: "Interaction authorization failed" });
|
|
390
377
|
return;
|
|
391
378
|
}
|
|
392
379
|
if (params.handleInteraction) try {
|
|
@@ -400,12 +387,12 @@ function createMattermostInteractionHandler(params) {
|
|
|
400
387
|
post: originalPost
|
|
401
388
|
});
|
|
402
389
|
if (response !== null) {
|
|
403
|
-
|
|
390
|
+
sendJsonWithoutCharset(res, 200, response);
|
|
404
391
|
return;
|
|
405
392
|
}
|
|
406
393
|
} catch (err) {
|
|
407
394
|
log?.(`mattermost interaction: custom handler failed: ${String(err)}`);
|
|
408
|
-
|
|
395
|
+
sendJsonWithoutCharset(res, 500, { error: "Interaction handler failed" });
|
|
409
396
|
return;
|
|
410
397
|
}
|
|
411
398
|
try {
|
|
@@ -430,7 +417,7 @@ function createMattermostInteractionHandler(params) {
|
|
|
430
417
|
} catch (err) {
|
|
431
418
|
log?.(`mattermost interaction: failed to update post ${payload.post_id}: ${String(err)}`);
|
|
432
419
|
}
|
|
433
|
-
|
|
420
|
+
sendJsonWithoutCharset(res, 200, {});
|
|
434
421
|
if (params.dispatchButtonClick) try {
|
|
435
422
|
await params.dispatchButtonClick({
|
|
436
423
|
channelId: payload.channel_id,
|