mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +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 name: string
|
||||||
public apiCall: Axios
|
public apiCall: Axios
|
||||||
public channels: Map<string, Channel>
|
public channels: Map<string, Channel>
|
||||||
|
public invitedChannels: Set<string>
|
||||||
public roomIdToChannel: Map<string, Channel>
|
public roomIdToChannel: Map<string, Channel>
|
||||||
public directRooms: Map<string, string[]>
|
public directRooms: Map<string, string[]>
|
||||||
private syncLocks: Set<Channel>
|
private syncLocks: Set<Channel>
|
||||||
|
@ -33,6 +34,7 @@ export class Server {
|
||||||
headers: {"Authorization": `Bearer ${this.config.accessToken}`}
|
headers: {"Authorization": `Bearer ${this.config.accessToken}`}
|
||||||
})
|
})
|
||||||
this.channels = new Map();
|
this.channels = new Map();
|
||||||
|
this.invitedChannels = new Set();
|
||||||
this.roomIdToChannel = new Map();
|
this.roomIdToChannel = new Map();
|
||||||
this.directRooms = new Map();
|
this.directRooms = new Map();
|
||||||
this.syncLocks = new Set();
|
this.syncLocks = new Set();
|
||||||
|
@ -74,13 +76,20 @@ export class Server {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
this.nextBatch = data.next_batch;
|
this.nextBatch = data.next_batch;
|
||||||
const rooms = data.rooms;
|
const rooms = data.rooms;
|
||||||
if (rooms && rooms['join']) {
|
if (rooms) {
|
||||||
for (const roomId of Object.keys(rooms.join)) {
|
if (rooms['join']) {
|
||||||
const targetChannel = this.getOrCreateIRCChannel(roomId);
|
for (const roomId of Object.keys(rooms.join)) {
|
||||||
rooms.join[roomId].timeline.events.forEach((nextEvent: any) => {
|
const targetChannel = this.getOrCreateIRCChannel(roomId);
|
||||||
if (targetChannel.isSynced())
|
rooms.join[roomId].timeline.events.forEach((nextEvent: any) => {
|
||||||
this.routeMatrixEvent(nextEvent, targetChannel);
|
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;
|
this.isSyncing = false;
|
||||||
|
@ -123,6 +132,7 @@ export class Server {
|
||||||
finishChannelSync(targetChannel: Channel) {
|
finishChannelSync(targetChannel: Channel) {
|
||||||
this.syncLocks.delete(targetChannel);
|
this.syncLocks.delete(targetChannel);
|
||||||
this.channels.delete(targetChannel.roomId);
|
this.channels.delete(targetChannel.roomId);
|
||||||
|
this.invitedChannels.delete(targetChannel.roomId);
|
||||||
this.channels.set(targetChannel.name, targetChannel);
|
this.channels.set(targetChannel.name, targetChannel);
|
||||||
this.roomIdToChannel.set(targetChannel.roomId, targetChannel);
|
this.roomIdToChannel.set(targetChannel.roomId, targetChannel);
|
||||||
this.clients.forEach(c => this.joinNewIRCClient(c, targetChannel));
|
this.clients.forEach(c => this.joinNewIRCClient(c, targetChannel));
|
||||||
|
@ -195,6 +205,7 @@ export class Server {
|
||||||
for (const channel of this.channels.values()) {
|
for (const channel of this.channels.values()) {
|
||||||
this.joinNewIRCClient(client, channel);
|
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