Skip to content

Commit 1cc6a91

Browse files
authored
Consolidate Synpase admin room details schema. (#907)
Change comes from mps-for-bot-sdk. We're not trusting the room list or the room details endpoint anymore.
1 parent f72c7fc commit 1cc6a91

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"matrix-appservice-bridge": "^10.3.1",
6565
"matrix-bot-sdk": "npm:@vector-im/matrix-bot-sdk@^0.7.1-element.6",
6666
"matrix-protection-suite": "npm:@gnuxie/[email protected]",
67-
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/[email protected].2",
67+
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/[email protected].3",
6868
"pg": "^8.8.0",
6969
"yaml": "^2.3.2"
7070
},

src/capabilities/SynapseAdminRoomTakedown/SynapseAdminRoomTakedown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class SynapseAdminRoomDetailsProvider implements RoomDetailsProvider {
3131
} else {
3232
return Ok({
3333
name: detailsResponse.ok?.name ?? undefined,
34-
creator: detailsResponse.ok?.creator,
34+
creator: detailsResponse.ok?.creator ?? undefined,
3535
avatar: detailsResponse.ok?.avatar ?? undefined,
3636
topic: detailsResponse.ok?.topic ?? undefined,
3737
joined_members: detailsResponse.ok?.joined_members ?? undefined,

src/protections/RoomTakedown/DiscoveredRoomStore.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import { isError, Ok, Result } from "@gnuxie/typescript-result";
66
import {
7+
roomIDServerName,
78
StringRoomID,
8-
userServerName,
99
} from "@the-draupnir-project/matrix-basic-types";
1010
import {
1111
Logger,
@@ -23,6 +23,23 @@ export type RoomToCheck = {
2323
details?: RoomBasicDetails | undefined;
2424
};
2525

26+
/**
27+
* Currently the store is polluted because of https://github.com/element-hq/synapse/issues/18563
28+
* Because of the fallout of this bug, there will be room details polluted in the following way:
29+
*
30+
* 1. empty string for `server`.
31+
* 2. empty string for `creator`.
32+
*
33+
* To cleanup, we probably need to destroy the details table entirely
34+
* and create a table for the server responsible for creating the room derived
35+
* from the room_id.
36+
* Then later if we find a way of obtaining the creator, we can store that
37+
* instead.
38+
*
39+
* The reason why this didn't happen in the first place is because we thought
40+
* that the creator would always be available and we would always derive the
41+
* server from the creator.
42+
*/
2643
export class StandardDiscoveredRoomStore
2744
extends EventEmitter
2845
implements RoomDiscovery
@@ -62,7 +79,7 @@ export class StandardDiscoveredRoomStore
6279
const storeResult = await this.hashStore.storeRoomIdentification({
6380
creator: details.creator,
6481
roomID: details.room_id,
65-
server: userServerName(details.creator),
82+
server: roomIDServerName(details.room_id),
6683
});
6784
if (isError(storeResult)) {
6885
log.error(

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,10 +2598,10 @@ matrix-appservice@^2.0.0:
25982598
request-promise "^4.2.6"
25992599
sanitize-html "^2.11.0"
26002600

2601-
"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/[email protected].2":
2602-
version "3.6.2"
2603-
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-3.6.2.tgz#c412ff58483c80ccc5c36a19054e8278163a4426"
2604-
integrity sha512-C9CtXXFYszUNJUR6rgEu6z9oyH56x12OYkce4/KKNUVMAaBAGQJmFI7yaRm+wA2XfIINJibJsHh1ddoBl7y/4A==
2601+
"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/[email protected].3":
2602+
version "3.6.3"
2603+
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-3.6.3.tgz#4c99dcde1762e6f4887dc3cf1ff9473f50f56f00"
2604+
integrity sha512-2ZTaD2pBOHjXnxHXTeU33YkxR3J3eC8d7Jj+h1hvCIhGCvSWJml48MIovYlR7/z3J0KWZLS/87s3/YsUV7uJPw==
26052605
dependencies:
26062606
"@gnuxie/typescript-result" "^1.0.0"
26072607
await-lock "^2.2.2"

0 commit comments

Comments
 (0)