quick fix to alert to any invited rooms

This commit is contained in:
emerson 2022-05-02 20:05:07 -04:00
parent d53ccee2a1
commit d18f6a699a

View file

@ -9,6 +9,7 @@ export class Server {
public name: string
public apiCall: Axios
public channels: Map<string, Channel>
public invitedChannels: Set<string>
public roomIdToChannel: Map<string, Channel>
public directRooms: Map<string, string[]>
private syncLocks: Set<Channel>
@ -33,6 +34,7 @@ export class Server {
headers: {"Authorization": `Bearer ${this.config.accessToken}`}
})
this.channels = new Map();
this.invitedChannels = new Set();
this.roomIdToChannel = new Map();
this.directRooms = new Map();
this.syncLocks = new Set();
@ -74,13 +76,20 @@ export class Server {
const data = response.data;
this.nextBatch = data.next_batch;
const rooms = data.rooms;
if (rooms && rooms['join']) {
for (const roomId of Object.keys(rooms.join)) {
const targetChannel = this.getOrCreateIRCChannel(roomId);
rooms.join[roomId].timeline.events.forEach((nextEvent: any) => {
if (targetChannel.isSynced())
this.routeMatrixEvent(nextEvent, targetChannel);
});
if (rooms) {
if (rooms['join']) {
for (const roomId of Object.keys(rooms.join)) {
const targetChannel = this.getOrCreateIRCChannel(roomId);
rooms.join[roomId].timeline.events.forEach((nextEvent: any) => {
if (targetChannel.isSynced())
this.routeMatrixEvent(nextEvent, targetChannel);
});
}
}
if (rooms['invite']) {
for (const roomId of Object.keys(rooms.invite)) {
this.invitedChannels.add(roomId);
}
}
}
this.isSyncing = false;
@ -123,6 +132,7 @@ export class Server {
finishChannelSync(targetChannel: Channel) {
this.syncLocks.delete(targetChannel);
this.channels.delete(targetChannel.roomId);
this.invitedChannels.delete(targetChannel.roomId);
this.channels.set(targetChannel.name, targetChannel);
this.roomIdToChannel.set(targetChannel.roomId, targetChannel);
this.clients.forEach(c => this.joinNewIRCClient(c, targetChannel));
@ -195,6 +205,7 @@ export class Server {
for (const channel of this.channels.values()) {
this.joinNewIRCClient(client, channel);
}
this.invitedChannels.forEach(roomId => this.sendToAll(this.name, "INVITE", [this.ourMatrixUser.nick, roomId], new Map()));
}
}