WIP: Applied feedback

This commit is contained in:
David Teller 2022-03-16 16:55:11 +01:00
parent 2813cfa2c6
commit 197a20b889
2 changed files with 11 additions and 3 deletions

View File

@ -103,6 +103,14 @@ export async function execSinceCommand(destinationRoomId: string, event: any, mj
mjolnir.client.unstableApis.addReactionToEvent(destinationRoomId, event['event_id'], '✅');
}
}
// Implementation of `execSinceCommand`, counts on caller to print errors.
//
// This method:
// - decodes all the arguments;
// - resolves any room alias into a room id;
// - attempts to execute action;
// - in case of success, returns `{ok: undefined}`, in case of error, returns `{error: string}`.
async function execSinceCommandAux(destinationRoomId: string, event: any, mjolnir: Mjolnir, tokens: ParseEntry[]): Promise<Result<undefined>> {
const [dateOrDurationToken, actionToken, maxEntriesToken, ...optionalTokens] = tokens;
@ -160,7 +168,7 @@ async function execSinceCommandAux(destinationRoomId: string, event: any, mjolni
const action: Action = actionResult.ok!;
// Now list affected rooms.
const rooms: Set<string> = new Set();
const rooms: Set</* room id */string> = new Set();
let reasonParts: string[] | undefined;
for (let token of optionalTokens) {
const maybeArg = getTokenAsString(reasonParts ? "[reason]" : "[room]", token);
@ -274,4 +282,4 @@ function makeJoinStatus(mjolnir: Mjolnir, targetRoomId: string, maxEntries: numb
html: `${joins.length} recent joins (cut at ${maxAgeHumanReadable} ago / ${maxEntries} entries): <ul> ${htmlFragments.join()} </ul>`,
text: `${joins.length} recent joins (cut at ${maxAgeHumanReadable} ago / ${maxEntries} entries):\n${textFragments.join("\n")}`
}
}
}

View File

@ -252,7 +252,7 @@ describe("Test: Testing RoomMemberManager", function() {
for (let array of [this.users, this.goodUsers, this.badUsers]) {
for (let client of array || []) {
await client.stop();
}
}
}
});