Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show helpful admin command error if it's a IrcProvisioningError #1702

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1702.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show a helpful error for !link/!unlink admin failures, rather than "Check the logs for details", in more cases.
9 changes: 8 additions & 1 deletion src/bridge/AdminRoomHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as RoomCreation from "./RoomCreation";
import { getBridgeVersion } from "matrix-appservice-bridge";
import { IdentGenerator } from "../irc/IdentGenerator";
import { Provisioner } from "../provisioning/Provisioner";
import { IrcProvisioningError } from "../provisioning/Schema";

const log = logging("AdminRoomHandler");

Expand Down Expand Up @@ -239,6 +240,9 @@ export class AdminRoomHandler {
}
catch (ex) {
log.error(`Failed to handle !plumb command:`, ex);
if (ex instanceof IrcProvisioningError) {
return new MatrixAction(ActionType.Notice, `Failed to plumb room. ${ex.message}`);
}
return new MatrixAction(ActionType.Notice, "Failed to plumb room. Check the logs for details.");
}
return new MatrixAction(ActionType.Notice, "Room plumbed.");
Expand Down Expand Up @@ -272,6 +276,9 @@ export class AdminRoomHandler {
}
catch (ex) {
log.error(`Failed to handle !unlink command:`, ex);
if (ex instanceof IrcProvisioningError) {
return new MatrixAction(ActionType.Notice, `Failed to plumb room. ${ex.message}`);
}
return new MatrixAction(ActionType.Notice, "Failed to unlink room. Check the logs for details.");
}
return new MatrixAction(ActionType.Notice, "Room unlinked.");
Expand All @@ -282,7 +289,7 @@ export class AdminRoomHandler {
// check that the server exists and that the user_id is on the whitelist
const ircChannel = args[0];
const key = args[1]; // keys can't have spaces in them, so we can just do this.
let errText = null;
let errText: string|null = null;
if (!ircChannel || !ircChannel.startsWith("#")) {
errText = "Format: '!join irc.example.com #channel [key]'";
}
Expand Down