requested changes

This commit is contained in:
H. Shay 2024-07-24 12:00:48 -07:00
parent 3aad2c5dd2
commit cee8ce308b
4 changed files with 12 additions and 14 deletions

View File

@ -485,7 +485,7 @@ export class Mjolnir {
return await this.client.doRequest("PUT", endpoint, null, body);
}
public async unSuspendSynapseUser(userId: string): Promise<any> {
public async unsuspendSynapseUser(userId: string): Promise<any> {
const endpoint = `/_synapse/admin/v1/suspend/${userId}`;
const body = {"suspend": false}
return await this.client.doRequest("PUT", endpoint, null, body);

View File

@ -44,7 +44,7 @@ import { parse as tokenize } from "shell-quote";
import { execSinceCommand } from "./SinceCommand";
import { execSetupProtectedRoom } from "./SetupDecentralizedReportingCommand";
import {execSuspendCommand} from "./SuspendCommand";
import {execUnSuspendCommand} from "./unSuspendCommand";
import {execUnsuspendCommand} from "./UnsuspendCommand";
export const COMMAND_PREFIX = "!mjolnir";
@ -133,7 +133,7 @@ export async function handleCommand(roomId: string, event: { content: { body: st
} else if (parts[1] === 'suspend' && parts.length > 2) {
return await execSuspendCommand(roomId, event, mjolnir, parts);
} else if (parts[1] === 'unsuspend' && parts.length > 2) {
return await execUnSuspendCommand(roomId, event, mjolnir, parts)
return await execUnsuspendCommand(roomId, event, mjolnir, parts)
} else {
// Help menu
const menu = "" +
@ -176,10 +176,8 @@ export async function handleCommand(roomId: string, event: { content: { body: st
"!mjolnir shutdown room <room alias/ID> [message] - Uses the bot's account to shut down a room, preventing access to the room on this server\n" +
"!mjolnir powerlevel <user ID> <power level> [room alias/ID] - Sets the power level of the user in the specified room (or all protected rooms)\n" +
"!mjolnir make admin <room alias> [user alias/ID] - Make the specified user or the bot itself admin of the room\n" +
"!mjolnir suspend <user ID> - Suspend the specified user"
+
"!mjolnir unsuspend <user ID> - Unsuspend the specified user"
+
"!mjolnir suspend <user ID> - Suspend the specified user" +
"!mjolnir unsuspend <user ID> - Unsuspend the specified user" +
"!mjolnir help - This menu\n"
const html = `<b>Mjolnir help:</b><br><pre><code>${htmlEscape(menu)}</code></pre>`;
const text = `Mjolnir help:\n${menu}`;

View File

@ -18,7 +18,7 @@ import {Mjolnir} from "../Mjolnir";
import {RichReply} from "matrix-bot-sdk";
export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const victim = parts[2];
const target = parts[2];
const isAdmin = await mjolnir.isSynapseAdmin();
if (!isAdmin) {
@ -29,8 +29,8 @@ export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mj
return;
}
await mjolnir.suspendSynapseUser(victim);
const msg = `User ${victim} has been suspended.`
await mjolnir.suspendSynapseUser(target);
const msg = `User ${target} has been suspended.`
const confirmation = RichReply.createFor(roomId, event, msg, msg);
confirmation['msgtype'] = "m.notice";
await mjolnir.client.sendMessage(roomId, confirmation)

View File

@ -17,8 +17,8 @@ limitations under the License.
import {Mjolnir} from "../Mjolnir";
import {RichReply} from "matrix-bot-sdk";
export async function execUnSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const victim = parts[2];
export async function execUnsuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const target = parts[2];
const isAdmin = await mjolnir.isSynapseAdmin();
if (!isAdmin) {
@ -29,8 +29,8 @@ export async function execUnSuspendCommand(roomId: string, event: any, mjolnir:
return;
}
await mjolnir.unSuspendSynapseUser(victim);
const msg = `User ${victim}'s suspension has been reversed.`
await mjolnir.unsuspendSynapseUser(target);
const msg = `User ${target}'s suspension has been reversed.`
const confirmation = RichReply.createFor(roomId, event, msg, msg);
confirmation['msgtype'] = "m.notice";
mjolnir.client.sendMessage(roomId, confirmation)