From 197a20b889f61b6d231a661614d022003bef7f8d Mon Sep 17 00:00:00 2001 From: David Teller Date: Wed, 16 Mar 2022 16:55:11 +0100 Subject: [PATCH] WIP: Applied feedback --- src/commands/SinceCommand.ts | 12 ++++++++++-- test/integration/roomMembersTest.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/commands/SinceCommand.ts b/src/commands/SinceCommand.ts index 472bf56..1e64757 100644 --- a/src/commands/SinceCommand.ts +++ b/src/commands/SinceCommand.ts @@ -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> { 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 = new Set(); + const rooms: Set = 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):
    ${htmlFragments.join()}
`, text: `${joins.length} recent joins (cut at ${maxAgeHumanReadable} ago / ${maxEntries} entries):\n${textFragments.join("\n")}` } -} \ No newline at end of file +} diff --git a/test/integration/roomMembersTest.ts b/test/integration/roomMembersTest.ts index 3100737..668c8f7 100644 --- a/test/integration/roomMembersTest.ts +++ b/test/integration/roomMembersTest.ts @@ -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(); - } + } } });