Skip to content

Commit

Permalink
Fix command setting state twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Dec 27, 2023
1 parent ee54eea commit 218aec4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Connections/SetupConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,14 @@ export class SetupConnection extends CommandConnection {
}
throw err;
});
if (!event || Object.keys(event).length === 0) {
if (!event || event.disabled === true || Object.keys(event).length === 0) {
throw new CommandError("Invalid webhook name", `No webhook by the name of "${name}" is configured.`);
}

await this.client.sendStateEvent(this.roomId, GenericHookConnection.CanonicalEventType, name, {});
await this.client.sendStateEvent(this.roomId, GenericHookConnection.CanonicalEventType, name, {
disabled: true
});

return this.client.sendHtmlNotice(this.roomId, md.renderInline(`Removed webhook \`${name}\``));
}

Expand Down

0 comments on commit 218aec4

Please sign in to comment.