Use reserver username

Check that we actually got roomData
This commit is contained in:
Till Faelligen 2022-02-15 17:58:36 +01:00
parent c08a8db23e
commit c3c55eb704
4 changed files with 14 additions and 13 deletions

View file

@ -72,7 +72,7 @@ global:
server_notices: server_notices:
enabled: false enabled: false
# The server localpart to be used when sending notices, ensure this is not yet taken # The server localpart to be used when sending notices, ensure this is not yet taken
local_part: "server" local_part: "_server"
# The displayname to be used when sending notices # The displayname to be used when sending notices
display_name: "Server alerts" display_name: "Server alerts"
# The mxid of the avatar to use # The mxid of the avatar to use

View file

@ -98,7 +98,8 @@ func (r *Leaver) performLeaveRoomByID(
}, accData); err != nil { }, accData); err != nil {
return nil, fmt.Errorf("unable to query account data") return nil, fmt.Errorf("unable to query account data")
} }
roomData := accData.RoomAccountData[req.RoomID]
if roomData, ok := accData.RoomAccountData[req.RoomID]; ok {
tagData, ok := roomData["m.tag"] tagData, ok := roomData["m.tag"]
if ok { if ok {
tags := gomatrix.TagContent{} tags := gomatrix.TagContent{}
@ -109,7 +110,7 @@ func (r *Leaver) performLeaveRoomByID(
return nil, fmt.Errorf("Unable to reject server notice invite") return nil, fmt.Errorf("Unable to reject server notice invite")
} }
} }
}
} }
// There's no invite pending, so first of all we want to find out // There's no invite pending, so first of all we want to find out

View file

@ -142,7 +142,7 @@ type ServerNotices struct {
func (c *ServerNotices) Defaults(generate bool) { func (c *ServerNotices) Defaults(generate bool) {
if generate { if generate {
c.LocalPart = "server" c.LocalPart = "_server"
c.DisplayName = "Server Alert" c.DisplayName = "Server Alert"
c.RoomName = "Server Alert" c.RoomName = "Server Alert"
c.AvatarURL = "" c.AvatarURL = ""

View file

@ -59,7 +59,7 @@ global:
username: metrics username: metrics
password: metrics password: metrics
server_notices: server_notices:
local_part: "server" local_part: "_server"
display_name: "Server alerts" display_name: "Server alerts"
avatar: "" avatar: ""
room_name: "Server Alerts" room_name: "Server Alerts"