diff --git a/dendrite-config.yaml b/dendrite-config.yaml index b4281806d..bc9220904 100644 --- a/dendrite-config.yaml +++ b/dendrite-config.yaml @@ -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 diff --git a/roomserver/internal/perform/perform_leave.go b/roomserver/internal/perform/perform_leave.go index 9f110d275..9fbd4a4ce 100644 --- a/roomserver/internal/perform/perform_leave.go +++ b/roomserver/internal/perform/perform_leave.go @@ -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 diff --git a/setup/config/config_global.go b/setup/config/config_global.go index b242c93eb..1440eba02 100644 --- a/setup/config/config_global.go +++ b/setup/config/config_global.go @@ -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 = "" diff --git a/setup/config/config_test.go b/setup/config/config_test.go index 8a012a7f0..b17837c7f 100644 --- a/setup/config/config_test.go +++ b/setup/config/config_test.go @@ -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"