Don't check PLs after all because for local aliases they are apparently irrelevant

This commit is contained in:
Neil Alexander 2021-07-21 15:35:10 +01:00
parent c683b7a323
commit 9925285a87
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -165,35 +165,6 @@ func SetLocalAlias(
return *resErr return *resErr
} }
// Check if the user has the power to update the aliases.
stateTuple := gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomPowerLevels,
StateKey: "",
}
stateReq := &roomserverAPI.QueryCurrentStateRequest{
RoomID: r.RoomID,
StateTuples: []gomatrixserverlib.StateKeyTuple{stateTuple},
}
stateRes := &roomserverAPI.QueryCurrentStateResponse{}
if err := rsAPI.QueryCurrentState(req.Context(), stateReq, stateRes); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("rsAPI.QueryCurrentState failed")
return util.ErrorResponse(fmt.Errorf("rsAPI.QueryCurrentState: %w", err))
}
if plEvent, ok := stateRes.StateEvents[stateTuple]; ok {
pls, err := plEvent.PowerLevels()
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("plEvent.PowerLevels failed")
return util.ErrorResponse(fmt.Errorf("plEvent.PowerLevels: %w", err))
}
if pls.UserLevel(device.UserID) < pls.EventLevel(gomatrixserverlib.MRoomCanonicalAlias, true) {
return util.JSONResponse{
Code: http.StatusForbidden,
JSON: jsonerror.Forbidden("You do not have permission to set aliases."),
}
}
}
queryReq := roomserverAPI.SetRoomAliasRequest{ queryReq := roomserverAPI.SetRoomAliasRequest{
UserID: device.UserID, UserID: device.UserID,
RoomID: r.RoomID, RoomID: r.RoomID,