From d1950fbb5419d0a297bbee8baed306e3cd980b78 Mon Sep 17 00:00:00 2001 From: gnuxie Date: Mon, 13 May 2024 16:23:26 +0100 Subject: [PATCH] Update for new MPS handleExternalInvite handle. --- package.json | 4 ++-- src/Draupnir.ts | 7 +++++-- yarn.lock | 16 ++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 34a254bc..d7e2dd61 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,8 @@ "js-yaml": "^4.1.0", "jsdom": "^24.0.0", "matrix-appservice-bridge": "^9.0.1", - "matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@0.20.0", - "matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.20.0", + "matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@0.21.0", + "matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.21.0", "parse-duration": "^1.0.2", "pg": "^8.8.0", "shell-quote": "^1.7.3", diff --git a/src/Draupnir.ts b/src/Draupnir.ts index 040ac520..5b7150e7 100644 --- a/src/Draupnir.ts +++ b/src/Draupnir.ts @@ -199,7 +199,10 @@ export class Draupnir implements Client { } public handleTimelineEvent(roomID: StringRoomID, event: RoomEvent): void { - Task(this.joinOnInviteListener(roomID, event)); + if (Value.Check(MembershipEvent, event) && event.content.membership === Membership.Invite && event.state_key === this.clientUserID) { + this.protectedRoomsSet.handleExternalInvite(roomID, event); + Task(this.joinOnInviteListener(roomID, event)); + } this.managementRoomMessageListener(roomID, event); this.reactionHandler.handleEvent(roomID, event); if (this.protectedRoomsSet.isProtectedRoom(roomID)) { @@ -250,7 +253,7 @@ export class Draupnir implements Client { * @param {boolean} options.autojoinOnlyIfManager Whether to only accept an invitation by a user present in the `managementRoom`. * @param {string} options.acceptInvitesFromSpace A space of users to accept invites from, ignores invites form users not in this space. */ - private async joinOnInviteListener(roomID: StringRoomID, event: RoomEvent): Promise { + private async joinOnInviteListener(roomID: StringRoomID, event: MembershipEvent): Promise { if (Value.Check(MembershipEvent, event) && event.state_key === this.clientUserID) { const inviteEvent = event; const reportInvite = async () => { diff --git a/yarn.lock b/yarn.lock index 7264e8d4..dbddfc48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2505,15 +2505,15 @@ matrix-appservice@^2.0.0: request-promise "^4.2.6" sanitize-html "^2.8.0" -"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.20.0": - version "0.20.0" - resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-0.20.0.tgz#c103fc6f66c14606c669f6e71de8049acf504b2b" - integrity sha512-HA85a64+2TqvgSY2us8wKBb7NoeAoeLBiIMf8btBVCJXppED+oiPxSdwsSy6nZmcWxgNUt1SEvlmhlUCm5EJGg== +"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-0.21.0.tgz#2b03a1409e01508635d31c9e0f7d3650d48467de" + integrity sha512-wRcNYrY8gDxX6ofPjRpE5DI+i+X0q5o2VqFXXYA2TSiYCues0B26DZeRH5qcw8pmMM+voCGSPurLD7RFnm1a8Q== -"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@0.20.0": - version "0.20.0" - resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-0.20.0.tgz#a1ed3a7a2c1ac9bcda870d2c035f165ff2fe376d" - integrity sha512-CHGhyVfmG7Jn8SsxYlvqfFxs5Fyhv0fCP3RVht5pzhErYlvjsdphBRNrkzmq87kNBOJo9kGQ8HWFhxOaU5GCkA== +"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@0.21.0": + version "0.21.0" + resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-0.21.0.tgz#9f4983cf1a2a6583f7d9ee6ea84fc4428f9add6b" + integrity sha512-hIZpkIv0bEl5aKMv/AzK9Lcbg6CD3lw5VDYQmv04pM2/ja4z5nCsxD9rWeEUl+1IP+i0RjFWLNnbhl8n9nPsnA== dependencies: await-lock "^2.2.2" crypto-js "^4.2.0"