mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-04-13 09:59:52 +00:00
quick fix to alert to any invited rooms
This commit is contained in:
parent
d53ccee2a1
commit
d18f6a699a
1 changed files with 18 additions and 7 deletions
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue