From 4105afd4ddb03748dd727c0d4df5dc896ec79ab8 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 21 Jul 2021 15:06:19 +0100 Subject: [PATCH] Don't return error if the state event fails --- roomserver/internal/alias.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/roomserver/internal/alias.go b/roomserver/internal/alias.go index 66491d045..9507d650f 100644 --- a/roomserver/internal/alias.go +++ b/roomserver/internal/alias.go @@ -77,7 +77,15 @@ func (r *RoomserverInternalAPI) SetRoomAlias( // 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. - return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, request.RoomID) + // + // From: https://spec.matrix.org/unstable/client-server-api/#delete_matrixclientr0directoryroomroomalias + // Note: Servers may choose to update the alt_aliases for the m.room.canonical_alias + // state event in the room when an alias is removed. Servers which choose to update + // the canonical alias event are recommended to, in addition to their other relevant + // permission checks, delete the alias and return a successful response even if the + // user does not have permission to update the m.room.canonical_alias event. + _ = r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID) + return nil } // GetRoomIDForAlias implements alias.RoomserverInternalAPI @@ -172,7 +180,15 @@ func (r *RoomserverInternalAPI) RemoveRoomAlias( // 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. - return r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID) + // + // From: https://spec.matrix.org/unstable/client-server-api/#delete_matrixclientr0directoryroomroomalias + // Note: Servers may choose to update the alt_aliases for the m.room.canonical_alias + // state event in the room when an alias is removed. Servers which choose to update + // the canonical alias event are recommended to, in addition to their other relevant + // permission checks, delete the alias and return a successful response even if the + // user does not have permission to update the m.room.canonical_alias event. + _ = r.sendUpdatedAliasesEvent(context.TODO(), request.UserID, roomID) + return nil } type roomAliasesContent struct {