mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-04-13 09:59:52 +00:00
make sure that two-person rooms are actually DMs
This commit is contained in:
parent
e0c19d55fc
commit
600c1cec8b
2 changed files with 15 additions and 1 deletions
|
@ -102,6 +102,8 @@ export class Channel {
|
|||
if (this.isSynced()) {
|
||||
if (this.matrixUsers.size === 2 && this.name === this.roomId) {
|
||||
const otherUser = [...this.matrixUsers.values()].filter(m => m.nick !== this.ircUser.nick);
|
||||
const directRoomsForUser = this.ircUser.directRooms.get(otherUser[0].mxid);
|
||||
if (directRoomsForUser && directRoomsForUser.includes(this.roomId))
|
||||
this.name = `&${otherUser[0].mxid.substring(1)}`
|
||||
}
|
||||
this.ircUser.finishChannelSync(this);
|
||||
|
|
|
@ -8,6 +8,7 @@ export class IRCUser {
|
|||
private clients: Set<Client>
|
||||
public channels: Map<string, Channel>
|
||||
public roomIdToChannel: Map<string, Channel>
|
||||
public directRooms: Map<string, string[]>
|
||||
private syncLocks: Set<Channel>
|
||||
public matrixUsers: Map<string, MatrixUser>
|
||||
public nickToMatrixUser: Map<string, MatrixUser>
|
||||
|
@ -27,6 +28,7 @@ export class IRCUser {
|
|||
this.clients = new Set();
|
||||
this.channels = new Map();
|
||||
this.roomIdToChannel = new Map();
|
||||
this.directRooms = new Map();
|
||||
this.syncLocks = new Set();
|
||||
this.matrixUsers = new Map();
|
||||
this.nickToMatrixUser = new Map();
|
||||
|
@ -45,6 +47,16 @@ export class IRCUser {
|
|||
this.isSyncing = false;
|
||||
this.currentSyncTime = 0;
|
||||
this.syncIntervalID = setInterval(this.doSync.bind(this), 2000);
|
||||
axios.get(`https://${this.homeserver}/_matrix/client/v3/user/${this.mxid}/account_data/m.direct?access_token=${this.accessToken}`).then(response => {
|
||||
if (!response.data)
|
||||
return;
|
||||
//@ts-ignore
|
||||
Object.entries(response.data).forEach(m => this.directRooms.set(m[0], m[1]));
|
||||
}).catch(e => {
|
||||
const errcode = e.response?.data?.errcode;
|
||||
if (errcode !== "M_NOT_FOUND")
|
||||
console.log(e);
|
||||
})
|
||||
}
|
||||
|
||||
getOrCreateMatrixUser(mxid: string): MatrixUser {
|
||||
|
|
Loading…
Add table
Reference in a new issue