mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -06:00
Don't check PLs after all because for local aliases they are apparently irrelevant
This commit is contained in:
parent
c683b7a323
commit
9925285a87
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue