From e13a76cef8612be0c549a2145c25a02d8c06f390 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 21 Jul 2021 13:45:26 +0100 Subject: [PATCH] Generate m.room.canonical_alias instead of legacy m.room.aliases --- roomserver/internal/alias.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/roomserver/internal/alias.go b/roomserver/internal/alias.go index f15881d75..ef81e157d 100644 --- a/roomserver/internal/alias.go +++ b/roomserver/internal/alias.go @@ -73,7 +73,7 @@ func (r *RoomserverInternalAPI) SetRoomAlias( return err } - // Send a m.room.aliases event with the updated list of aliases for this room + // Send a m.room.canonical_alias event with the updated list of aliases for this room // At this point we've already committed the alias to the database so we // shouldn't cancel this request. // TODO: Ensure that we send unsent events when if server restarts. @@ -176,7 +176,8 @@ func (r *RoomserverInternalAPI) RemoveRoomAlias( } type roomAliasesContent struct { - Aliases []string `json:"aliases"` + Alias string `json:"alias"` + Aliases []string `json:"alt_aliases"` } // Build the updated m.room.aliases event to send to the room after addition or @@ -189,7 +190,7 @@ func (r *RoomserverInternalAPI) sendUpdatedAliasesEvent( builder := gomatrixserverlib.EventBuilder{ Sender: userID, RoomID: roomID, - Type: "m.room.aliases", + Type: gomatrixserverlib.MRoomCanonicalAlias, StateKey: &serverName, } @@ -199,7 +200,9 @@ func (r *RoomserverInternalAPI) sendUpdatedAliasesEvent( if err != nil { return err } - content := roomAliasesContent{Aliases: aliases} + content := roomAliasesContent{ + Aliases: aliases, + } rawContent, err := json.Marshal(content) if err != nil { return err