mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
wip
This commit is contained in:
parent
fb52e3dcb2
commit
58e8174378
@ -384,6 +384,19 @@ export class Mjolnir {
|
|||||||
this.protectedRoomsTracker.removeProtectedRoom(roomId);
|
this.protectedRoomsTracker.removeProtectedRoom(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async addProtectedSpace(roomId: string): Promise<void> {
|
||||||
|
await this.protectedRoomsConfig.addProtectedSpace(roomId);
|
||||||
|
await this.protectSpace(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async protectSpace(roomId: string): Promise<void> {
|
||||||
|
// create a ProtectedSpace and keep that somewhere,
|
||||||
|
// protected space could use ProtectedRoomSet for all its rooms.
|
||||||
|
// don't bother with recursively following spaces yet, but we probably need something like
|
||||||
|
// m.space.parent for that to work properly since anyone can add any room to spaces.
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resynchronize the protected rooms with rooms that the mjolnir user is joined to.
|
* Resynchronize the protected rooms with rooms that the mjolnir user is joined to.
|
||||||
* This is to implement `config.protectAllJoinedRooms` functionality.
|
* This is to implement `config.protectAllJoinedRooms` functionality.
|
||||||
|
@ -19,6 +19,16 @@ import { extractRequestError, LogService, MatrixClient, Permalinks } from "matri
|
|||||||
import { IConfig } from "./config";
|
import { IConfig } from "./config";
|
||||||
const PROTECTED_ROOMS_EVENT_TYPE = "org.matrix.mjolnir.protected_rooms";
|
const PROTECTED_ROOMS_EVENT_TYPE = "org.matrix.mjolnir.protected_rooms";
|
||||||
|
|
||||||
|
interface ProtectedRoomsAccountData {
|
||||||
|
rooms: string[],
|
||||||
|
spaces: [
|
||||||
|
{
|
||||||
|
room_id: string,
|
||||||
|
recursive: boolean,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the set of rooms that the user has EXPLICITLY asked to be protected.
|
* Manages the set of rooms that the user has EXPLICITLY asked to be protected.
|
||||||
*/
|
*/
|
||||||
@ -64,7 +74,7 @@ export default class ProtectedRoomsConfig {
|
|||||||
public async loadProtectedRoomsFromAccountData(): Promise<void> {
|
public async loadProtectedRoomsFromAccountData(): Promise<void> {
|
||||||
LogService.debug("ProtectedRoomsConfig", "Loading protected rooms...");
|
LogService.debug("ProtectedRoomsConfig", "Loading protected rooms...");
|
||||||
try {
|
try {
|
||||||
const data: { rooms?: string[] } | null = await this.client.getAccountData(PROTECTED_ROOMS_EVENT_TYPE);
|
const data: ProtectedRoomsAccountData | null = await this.client.getAccountData(PROTECTED_ROOMS_EVENT_TYPE);
|
||||||
if (data && data['rooms']) {
|
if (data && data['rooms']) {
|
||||||
for (const roomId of data['rooms']) {
|
for (const roomId of data['rooms']) {
|
||||||
this.explicitlyProtectedRooms.add(roomId);
|
this.explicitlyProtectedRooms.add(roomId);
|
||||||
|
1
src/ProtectedSpace.ts
Normal file
1
src/ProtectedSpace.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import { Space } from "matrix-bot-sdk";
|
Loading…
Reference in New Issue
Block a user