Don't return nonsense canonical room aliases in the public rooms responses

This commit is contained in:
Neil Alexander 2021-08-27 16:10:21 +01:00
parent 2dd5fd1fd6
commit f0d38227fe
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 6 additions and 2 deletions

View file

@ -156,7 +156,9 @@ func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.Room
case topicTuple: case topicTuple:
pub.Topic = contentVal pub.Topic = contentVal
case canonicalTuple: case canonicalTuple:
pub.CanonicalAlias = contentVal if _, _, err := gomatrixserverlib.SplitID('#', contentVal); err == nil {
pub.CanonicalAlias = contentVal
}
case visibilityTuple: case visibilityTuple:
pub.WorldReadable = contentVal == "world_readable" pub.WorldReadable = contentVal == "world_readable"
// need both of these to determine whether guests can join // need both of these to determine whether guests can join

View file

@ -215,7 +215,9 @@ func PopulatePublicRooms(ctx context.Context, roomIDs []string, rsAPI Roomserver
case topicTuple: case topicTuple:
pub.Topic = contentVal pub.Topic = contentVal
case canonicalTuple: case canonicalTuple:
pub.CanonicalAlias = contentVal if _, _, err := gomatrixserverlib.SplitID('#', contentVal); err == nil {
pub.CanonicalAlias = contentVal
}
case visibilityTuple: case visibilityTuple:
pub.WorldReadable = contentVal == "world_readable" pub.WorldReadable = contentVal == "world_readable"
// need both of these to determine whether guests can join // need both of these to determine whether guests can join