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:
enabled: false
# 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
display_name: "Server alerts"
# The mxid of the avatar to use

View file

@ -98,18 +98,19 @@ func (r *Leaver) performLeaveRoomByID(
}, accData); err != nil {
return nil, fmt.Errorf("unable to query account data")
}
roomData := accData.RoomAccountData[req.RoomID]
tagData, ok := roomData["m.tag"]
if ok {
tags := gomatrix.TagContent{}
if err = json.Unmarshal(tagData, &tags); err != nil {
return nil, fmt.Errorf("unable to unmarshal tag content")
}
if _, ok = tags.Tags["m.server_notice"]; ok {
return nil, fmt.Errorf("Unable to reject server notice invite")
if roomData, ok := accData.RoomAccountData[req.RoomID]; ok {
tagData, ok := roomData["m.tag"]
if ok {
tags := gomatrix.TagContent{}
if err = json.Unmarshal(tagData, &tags); err != nil {
return nil, fmt.Errorf("unable to unmarshal tag content")
}
if _, ok = tags.Tags["m.server_notice"]; ok {
return nil, fmt.Errorf("Unable to reject server notice invite")
}
}
}
}
// 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) {
if generate {
c.LocalPart = "server"
c.LocalPart = "_server"
c.DisplayName = "Server Alert"
c.RoomName = "Server Alert"
c.AvatarURL = ""

View file

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