send topic changes to IRC, fixes #4

This commit is contained in:
emerson 2021-12-07 12:15:03 -05:00
parent 7fe43f2df5
commit fde0118d38
No known key found for this signature in database
GPG key ID: 270669502DA603E3
2 changed files with 17 additions and 3 deletions

View file

@ -29,7 +29,7 @@ That said, it is usable for basic chatting.
| Channel kicks | ✅ | ❌ ||
| Channel bans | 🟨 | ❌ | Bans show up on IRC as kicks |
| Channel invites | ✅ | ❌ ||
| Channel topics | | ❌ ||
| Channel topics | | ❌ ||
| Channel powers | ❌ | ❌ ||
| Encrypted rooms | ❌ | ❌ ||
| Message replies <small>(IRCv3)</small> | ❌ | ❌ ||

View file

@ -266,8 +266,22 @@ export class Channel {
}
handleMatrixTopic(event: any) {
this.topic.set("text", event["content"]["topic"]);
this.topic.set("timestamp", event["origin_server_ts"].toString())
const topicText = event["content"]?.["topic"];
if (!topicText)
return;
const topicSetter = this.server.getOrCreateMatrixUser(event["sender"]);
const topicTS: string = event["origin_server_ts"].toString();
this.topic.set("text", topicText);
this.topic.set("timestamp", topicTS.substring(0,10))
this.topic.set('setter', topicSetter.nick);
const messageTags = new Map();
messageTags.set('msgid', event["event_id"]);
messageTags.set('account', topicSetter.accountName);
messageTags.set('time', new Date(event["origin_server_ts"]).toISOString())
this.ircUsers.forEach((user) => {
user.sendToAll(topicSetter.getMask(), 'TOPIC', [this.name, topicText], messageTags);
});
}
handleMatrixJoinRule(event: any) {