Skip to content

Commit

Permalink
Replace shutdown_room API with DELETE /_synapse/admin/v1/rooms/<room_…
Browse files Browse the repository at this point in the history
…id> - Resolves #76, closes #96

As per matrix-org/synapse#9052, shutdown_room is going away, to be replaced with DELETE /_synapse/admin/v1/rooms/<room_id>.
  • Loading branch information
Yoric committed Aug 17, 2021
1 parent bc222e2 commit 62b30b1
Show file tree
Hide file tree
Showing 4 changed files with 502 additions and 26 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"test": "ts-mocha --project ./tsconfig.json test/**/*.ts"
},
"devDependencies": {
"@types/mocha": "^8.2.2",
"@types/node": "11",
"@types/mocha": "^9.0.0",
"@types/node": "^16.4.5",
"eslint": "^7.31.0",
"expect": "^27.0.6",
"mocha": "^9.0.1",
"ts-mocha": "^8.0.0",
"tslint": "^6.1.3",
"typescript": "^4.3.5"
"typescript": "^4.3.5",
"typescript-formatter": "^7.2.2"
},
"dependencies": {
"config": "^3.3.6",
Expand Down
8 changes: 5 additions & 3 deletions src/Mjolnir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,12 @@ export class Mjolnir {
return await this.client.doRequest("POST", endpoint);
}

public async shutdownSynapseRoom(roomId: string): Promise<any> {
const endpoint = `/_synapse/admin/v1/shutdown_room/${roomId}`;
return await this.client.doRequest("POST", endpoint, null, {
public async shutdownSynapseRoom(roomId: string, message?: string): Promise<any> {
const endpoint = `/_synapse/admin/v1/rooms/${roomId}`;
return await this.client.doRequest("DELETE", endpoint, null, {
new_room_user_id: await this.client.getUserId(),
block: true,
message: message || "This room was shutdown by a moderator"
});
}
}
4 changes: 2 additions & 2 deletions src/commands/ShutdownRoomCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";

// !mjolnir shutdown room <room>
// !mjolnir shutdown room <room> [<message>]
export async function execShutdownRoomCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const victim = parts[3];

Expand All @@ -30,6 +30,6 @@ export async function execShutdownRoomCommand(roomId: string, event: any, mjolni
return;
}

await mjolnir.shutdownSynapseRoom(await mjolnir.client.resolveRoom(victim));
await mjolnir.shutdownSynapseRoom(await mjolnir.client.resolveRoom(victim), parts[4]);
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅');
}
Loading

0 comments on commit 62b30b1

Please sign in to comment.