mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Try using power levels instead
This commit is contained in:
parent
2d91fe0df1
commit
fcf21da988
1 changed files with 18 additions and 9 deletions
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
fsAPI "github.com/matrix-org/dendrite/federationsender/api"
|
fsAPI "github.com/matrix-org/dendrite/federationsender/api"
|
||||||
"github.com/matrix-org/dendrite/internal/eventutil"
|
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
|
||||||
rsAPI "github.com/matrix-org/dendrite/roomserver/api"
|
rsAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||||
"github.com/matrix-org/dendrite/roomserver/internal/helpers"
|
"github.com/matrix-org/dendrite/roomserver/internal/helpers"
|
||||||
"github.com/matrix-org/dendrite/roomserver/internal/input"
|
"github.com/matrix-org/dendrite/roomserver/internal/input"
|
||||||
|
@ -259,19 +258,29 @@ func (r *Joiner) performJoinRoomByID(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !success {
|
if !success {
|
||||||
queryReq := &api.QueryMembershipsForRoomRequest{}
|
var powerLevelsEvent *gomatrixserverlib.HeaderedEvent
|
||||||
queryRes := &api.QueryMembershipsForRoomResponse{}
|
var powerLevelsContent gomatrixserverlib.PowerLevelContent
|
||||||
if err = r.RSAPI.QueryMembershipsForRoom(ctx, queryReq, queryRes); err != nil {
|
powerLevelsEvent, err = r.DB.GetStateEvent(ctx, req.RoomIDOrAlias, gomatrixserverlib.MRoomPowerLevels, "")
|
||||||
return "", "", &api.PerformError{
|
if err != nil {
|
||||||
Code: rsAPI.PerformErrorBadRequest,
|
return "", "", &rsAPI.PerformError{
|
||||||
Msg: fmt.Sprintf("Can't satisfy restricted join to room %q locally: %s", req.RoomIDOrAlias, err),
|
Code: rsAPI.PerformErrorNotAllowed,
|
||||||
|
Msg: fmt.Sprintf("Unable to retrieve the power levels: %s", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(powerLevelsEvent.Content(), &powerLevelsContent); err != nil {
|
||||||
|
return "", "", &rsAPI.PerformError{
|
||||||
|
Code: rsAPI.PerformErrorNotAllowed,
|
||||||
|
Msg: fmt.Sprintf("Unable to parse the power levels: %s", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var serverName gomatrixserverlib.ServerName
|
var serverName gomatrixserverlib.ServerName
|
||||||
joinEvents:
|
joinEvents:
|
||||||
for _, q := range queryRes.JoinEvents {
|
for userID, pl := range powerLevelsContent.Users {
|
||||||
_, serverName, err = gomatrixserverlib.SplitID('@', *q.StateKey)
|
if pl <= powerLevelsContent.Invite {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_, serverName, err = gomatrixserverlib.SplitID('@', userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue