1
0
Fork 0

store room name changes to nick in db

This commit is contained in:
Cadence Ember 2023-08-26 18:58:41 +12:00
parent 88eb8c2290
commit df651241a5
2 changed files with 21 additions and 1 deletions

View file

@ -80,3 +80,14 @@ async event => {
const url = event.content.url || null
db.prepare("UPDATE channel_room SET custom_avatar = ? WHERE room_id = ?").run(url, event.room_id)
}))
sync.addTemporaryListener(as, "type:m.room.name", guard("m.room.name",
/**
* @param {Ty.Event.StateOuter<Ty.Event.M_Room_Name>} event
*/
async event => {
if (event.state_key !== "") return
if (utils.eventSenderIsFromDiscord(event.sender)) return
const name = event.content.name || null
db.prepare("UPDATE channel_room SET nick = ? WHERE room_id = ?").run(name, event.room_id)
}))

11
types.d.ts vendored
View file

@ -70,7 +70,12 @@ export namespace Event {
msgtype: "m.text" | "m.emote"
body: string
format?: "org.matrix.custom.html"
formatted_body?: string
formatted_body?: string,
"m.relates_to"?: {
"m.in_reply_to": {
event_id: string
}
}
}
export type M_Room_Member = {
@ -84,6 +89,10 @@ export namespace Event {
url?: string
}
export type M_Room_Name = {
name?: string
}
export type M_Reaction = {
"m.relates_to": {
rel_type: "m.annotation"