From 0d116d92224040526094dd26dd054f91a8267c49 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Fri, 17 Apr 2020 12:17:20 +0100 Subject: [PATCH] Allow anyone to publish rooms (#971) * Allow anyone to publish rooms * Formatting and unused var * Review comments --- common/eventcontent.go | 1 + publicroomsapi/directory/directory.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/eventcontent.go b/common/eventcontent.go index c07c56276..f3817ba68 100644 --- a/common/eventcontent.go +++ b/common/eventcontent.go @@ -48,6 +48,7 @@ func InitialPowerLevelsContent(roomCreator string) (c gomatrixserverlib.PowerLev "m.room.history_visibility": 100, "m.room.canonical_alias": 50, "m.room.avatar": 50, + "m.room.aliases": 0, // anyone can publish aliases by default. Has to be 0 else state_default is used. } c.Users = map[string]int64{roomCreator: 100} return c diff --git a/publicroomsapi/directory/directory.go b/publicroomsapi/directory/directory.go index 1e305f3ca..837018e64 100644 --- a/publicroomsapi/directory/directory.go +++ b/publicroomsapi/directory/directory.go @@ -92,9 +92,9 @@ func SetVisibility( util.GetLogger(req.Context()).WithError(err).Error("could not query events from room") return jsonerror.InternalServerError() } - power, _ := gomatrixserverlib.NewPowerLevelContentFromEvent(queryEventsRes.StateEvents[0].Event) - // Check if the user's power is greater than power required to change m.room.aliases event + // NOTSPEC: Check if the user's power is greater than power required to change m.room.aliases event + power, _ := gomatrixserverlib.NewPowerLevelContentFromEvent(queryEventsRes.StateEvents[0].Event) if power.UserLevel(dev.UserID) < power.EventLevel(gomatrixserverlib.MRoomAliases, true) { return util.JSONResponse{ Code: http.StatusForbidden,