mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +00:00
Better channel naming and renaming.
Still a few weird bugs, but it's better now
This commit is contained in:
parent
ccfd571e13
commit
4b8ee81b23
4 changed files with 32 additions and 3 deletions
|
@ -32,7 +32,8 @@ That said, it is usable for basic chatting.
|
||||||
| Channel topics | ✅ | ❌ ||
|
| Channel topics | ✅ | ❌ ||
|
||||||
| Channel powers | ❌ | ❌ ||
|
| Channel powers | ❌ | ❌ ||
|
||||||
| Encrypted rooms | ❌ | ❌ ||
|
| Encrypted rooms | ❌ | ❌ ||
|
||||||
| Message replies <small>(IRCv3)</small> | ❌ | ❌ ||
|
| Channel renaming <small>(IRCv3)</small> | 🟨 | ❌ | Only when the canonical alias changes |
|
||||||
|
| Message replies <small>(IRCv3)</small> | ✅ | ❌ ||
|
||||||
| Message reactions <small>(IRCv3)</small> | ❌ | ❌ ||
|
| Message reactions <small>(IRCv3)</small> | ❌ | ❌ ||
|
||||||
| Chat history <small>(IRCv3)</small> | ❌ | ❌ ||
|
| Chat history <small>(IRCv3)</small> | ❌ | ❌ ||
|
||||||
| Multiline messages <small>(IRCv3)</small> | ❌ | ❌ ||
|
| Multiline messages <small>(IRCv3)</small> | ❌ | ❌ ||
|
||||||
|
|
|
@ -43,6 +43,25 @@ export class Channel {
|
||||||
return opStatus;
|
return opStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateRoomName(newNameEvent: any) {
|
||||||
|
const newName: string = newNameEvent["content"]["alias"];
|
||||||
|
if (!newName || newName === this.name)
|
||||||
|
return;
|
||||||
|
const oldName = this.name;
|
||||||
|
this.name = newName;
|
||||||
|
this.ircUsers.forEach((user, username) => {
|
||||||
|
user.getClients().forEach(client => {
|
||||||
|
if (client.enabledCaps.has("draft/channel-rename")) {
|
||||||
|
client.sendMessage(this.server.name, "RENAME", [oldName, this.name, "New channel name set"], new Map());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
client.sendMessage(this.server.name, "PART", [oldName, "Renaming channel"], new Map());
|
||||||
|
this.joinNewIRCClient(client, new Map());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
joinNewIRCClient(client: Client, passedTags: Map<string, string>) {
|
joinNewIRCClient(client: Client, passedTags: Map<string, string>) {
|
||||||
if (!client.user)
|
if (!client.user)
|
||||||
return;
|
return;
|
||||||
|
@ -126,6 +145,9 @@ export class Channel {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (event["type"]) {
|
switch (event["type"]) {
|
||||||
|
case 'm.room.canonical_alias':
|
||||||
|
this.updateRoomName(event);
|
||||||
|
break;
|
||||||
case 'm.room.guest_access':
|
case 'm.room.guest_access':
|
||||||
this.handleMatrixGuestAccess(event);
|
this.handleMatrixGuestAccess(event);
|
||||||
break;
|
break;
|
||||||
|
@ -166,7 +188,6 @@ export class Channel {
|
||||||
case 'm.room.bot.options':
|
case 'm.room.bot.options':
|
||||||
case 'm.room.pinned_events':
|
case 'm.room.pinned_events':
|
||||||
case 'm.room.tombstone':
|
case 'm.room.tombstone':
|
||||||
case 'm.room.canonical_alias':
|
|
||||||
case 'm.room.server_acl':
|
case 'm.room.server_acl':
|
||||||
case 'org.matrix.room.preview_urls':
|
case 'org.matrix.room.preview_urls':
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,6 +23,7 @@ export class Client {
|
||||||
["account-tag", ""],
|
["account-tag", ""],
|
||||||
["batch", ""],
|
["batch", ""],
|
||||||
["draft/chathistory", ""],
|
["draft/chathistory", ""],
|
||||||
|
["draft/channel-rename", ""],
|
||||||
["echo-message", ""],
|
["echo-message", ""],
|
||||||
["draft/event-playback", ""],
|
["draft/event-playback", ""],
|
||||||
["extended-join", ""],
|
["extended-join", ""],
|
||||||
|
@ -190,11 +191,13 @@ export class Client {
|
||||||
if (this.user === null)
|
if (this.user === null)
|
||||||
return;
|
return;
|
||||||
if (rooms['join']) {
|
if (rooms['join']) {
|
||||||
|
const joinedRooms: Set<Channel> = new Set();
|
||||||
for (const roomId of Object.keys(rooms.join)) {
|
for (const roomId of Object.keys(rooms.join)) {
|
||||||
const targetChannel = this.server.getOrCreateIRCChannel(roomId);
|
const targetChannel = this.server.getOrCreateIRCChannel(roomId);
|
||||||
this.user.channels.add(targetChannel);
|
joinedRooms.add(targetChannel);
|
||||||
rooms.join[roomId].state.events.forEach((nextEvent: any) => targetChannel.routeMatrixEvent(nextEvent));
|
rooms.join[roomId].state.events.forEach((nextEvent: any) => targetChannel.routeMatrixEvent(nextEvent));
|
||||||
}
|
}
|
||||||
|
joinedRooms.forEach(c => {if (this.user !== null) this.user.channels.add(c)});
|
||||||
}
|
}
|
||||||
if (this.user === null)
|
if (this.user === null)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -44,6 +44,10 @@ export class IRCUser {
|
||||||
return `${this.nick}!${this.ident}@${this.hostname}`;
|
return `${this.nick}!${this.ident}@${this.hostname}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getClients(): Set<Client> {
|
||||||
|
return this.clients;
|
||||||
|
}
|
||||||
|
|
||||||
addClient(client: Client, passedTags: Map<string, string>) {
|
addClient(client: Client, passedTags: Map<string, string>) {
|
||||||
this.clients.add(client);
|
this.clients.add(client);
|
||||||
if (this.nextBatch !== "") {
|
if (this.nextBatch !== "") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue