mattermost: align slash callback types with latest plugin runtime

This commit is contained in:
Muhammed Mukhthar CM
2026-03-03 04:31:37 +00:00
parent 281ba91a86
commit 46cc6368a0
3 changed files with 13 additions and 5 deletions

View File

@@ -10,9 +10,10 @@ function createRequest(params: {
body?: string;
contentType?: string;
}): IncomingMessage {
const req = new PassThrough() as IncomingMessage;
req.method = params.method ?? "POST";
req.headers = {
const req = new PassThrough();
const incoming = req as unknown as IncomingMessage;
incoming.method = params.method ?? "POST";
incoming.headers = {
"content-type": params.contentType ?? "application/x-www-form-urlencoded",
};
process.nextTick(() => {
@@ -21,7 +22,7 @@ function createRequest(params: {
}
req.end();
});
return req;
return incoming;
}
function createResponse(): {

View File

@@ -185,7 +185,12 @@ async function authorizeSlashInvocation(params: {
const configAllowFrom = normalizeAllowList(account.config.allowFrom ?? []);
const configGroupAllowFrom = normalizeAllowList(account.config.groupAllowFrom ?? []);
const storeAllowFrom = normalizeAllowList(
await core.channel.pairing.readAllowFromStore("mattermost").catch(() => []),
await core.channel.pairing
.readAllowFromStore({
channel: "mattermost",
accountId: account.accountId,
})
.catch(() => []),
);
const effectiveAllowFrom = Array.from(new Set([...configAllowFrom, ...storeAllowFrom]));
const effectiveGroupAllowFrom = Array.from(
@@ -254,6 +259,7 @@ async function authorizeSlashInvocation(params: {
if (dmPolicy === "pairing") {
const { code } = await core.channel.pairing.upsertPairingRequest({
channel: "mattermost",
accountId: account.accountId,
id: senderId,
meta: { name: senderName },
});

View File

@@ -305,6 +305,7 @@ export function registerSlashCommandRoute(api: OpenClawPluginApi) {
for (const callbackPath of callbackPaths) {
api.registerHttpRoute({
path: callbackPath,
auth: "plugin",
handler: routeHandler,
});
api.logger.info?.(`mattermost: registered slash command callback at ${callbackPath}`);