mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 14:57:27 +00:00
fix(mattermost): harden slash abort/lookup error paths
This commit is contained in:
@@ -1163,7 +1163,10 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
|
||||
// Clean up slash commands on shutdown
|
||||
if (slashEnabled) {
|
||||
const onAbortCleanup = () => {
|
||||
const runAbortCleanup = () => {
|
||||
if (slashShutdownCleanup) {
|
||||
return;
|
||||
}
|
||||
// Snapshot registered commands before deactivating state.
|
||||
// This listener may run concurrently with startup in a new process, so we keep
|
||||
// monitor shutdown alive until the remote cleanup completes.
|
||||
@@ -1179,7 +1182,12 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}
|
||||
runtime.error?.(`mattermost: slash cleanup failed: ${String(err)}`);
|
||||
});
|
||||
};
|
||||
opts.abortSignal?.addEventListener("abort", onAbortCleanup, { once: true });
|
||||
|
||||
if (opts.abortSignal?.aborted) {
|
||||
runAbortCleanup();
|
||||
} else {
|
||||
opts.abortSignal?.addEventListener("abort", runAbortCleanup, { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
await runWithReconnect(connectOnce, {
|
||||
|
||||
@@ -132,8 +132,9 @@ async function authorizeSlashInvocation(params: {
|
||||
channelId: string;
|
||||
senderId: string;
|
||||
senderName: string;
|
||||
log?: (msg: string) => void;
|
||||
}): Promise<SlashInvocationAuth> {
|
||||
const { account, cfg, client, commandText, channelId, senderId, senderName } = params;
|
||||
const { account, cfg, client, commandText, channelId, senderId, senderName, log } = params;
|
||||
const core = getMattermostRuntime();
|
||||
|
||||
// Resolve channel info so we can enforce DM vs group/channel policies.
|
||||
@@ -443,6 +444,7 @@ export function createSlashCommandHttpHandler(params: SlashHttpHandlerParams) {
|
||||
channelId,
|
||||
senderId,
|
||||
senderName,
|
||||
log,
|
||||
});
|
||||
|
||||
if (!auth.ok) {
|
||||
|
||||
Reference in New Issue
Block a user