mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Fix logic error on context history visibility (#2211)
This commit is contained in:
parent
aa6bbf484a
commit
bbe7d37928
1 changed files with 4 additions and 3 deletions
|
@ -64,7 +64,7 @@ func Context(
|
||||||
ctx := req.Context()
|
ctx := req.Context()
|
||||||
membershipRes := roomserver.QueryMembershipForUserResponse{}
|
membershipRes := roomserver.QueryMembershipForUserResponse{}
|
||||||
membershipReq := roomserver.QueryMembershipForUserRequest{UserID: device.UserID, RoomID: roomID}
|
membershipReq := roomserver.QueryMembershipForUserRequest{UserID: device.UserID, RoomID: roomID}
|
||||||
if err := rsAPI.QueryMembershipForUser(ctx, &membershipReq, &membershipRes); err != nil {
|
if err = rsAPI.QueryMembershipForUser(ctx, &membershipReq, &membershipRes); err != nil {
|
||||||
logrus.WithError(err).Error("unable to fo membership")
|
logrus.WithError(err).Error("unable to fo membership")
|
||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
}
|
}
|
||||||
|
@ -86,11 +86,12 @@ func Context(
|
||||||
state, _ := syncDB.CurrentState(ctx, roomID, &stateFilter, nil)
|
state, _ := syncDB.CurrentState(ctx, roomID, &stateFilter, nil)
|
||||||
// verify the user is allowed to see the context for this room/event
|
// verify the user is allowed to see the context for this room/event
|
||||||
for _, x := range state {
|
for _, x := range state {
|
||||||
hisVis, err := x.HistoryVisibility()
|
var hisVis string
|
||||||
|
hisVis, err = x.HistoryVisibility()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
allowed := hisVis != "world_readable" && membershipRes.Membership == "join"
|
allowed := hisVis == gomatrixserverlib.WorldReadable || membershipRes.Membership == gomatrixserverlib.Join
|
||||||
if !allowed {
|
if !allowed {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden,
|
Code: http.StatusForbidden,
|
||||||
|
|
Loading…
Reference in a new issue