diff options
author | oliverpool <3864879+oliverpool@users.noreply.github.com> | 2020-08-25 22:04:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 21:04:35 +0100 |
commit | 3205b9212d76f61301efae3c554bf9c3fbfc94c8 (patch) | |
tree | 6ec60e814c018c85e88ccf3acba1206b43adc96c /clientapi/routing/membership.go | |
parent | 55498c8deb262e564e1b79bf4409eb5593f3034e (diff) |
[readability] use event.StateKeyEquals where relevant and minor for-loop refactoring (#1339)
* use event.StateKeyEquals where relevant
Signed-off-by: Olivier Charvin <git@olivier.pfad.fr>
* use userID
Diffstat (limited to 'clientapi/routing/membership.go')
-rw-r--r-- | clientapi/routing/membership.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go index 37fafa5a..5d635c01 100644 --- a/clientapi/routing/membership.go +++ b/clientapi/routing/membership.go @@ -388,15 +388,20 @@ func checkMemberInRoom(ctx context.Context, stateAPI currentstateAPI.CurrentStat e := jsonerror.InternalServerError() return &e } - ev, ok := membershipRes.StateEvents[tuple] - if !ok { + ev := membershipRes.StateEvents[tuple] + if ev == nil { return &util.JSONResponse{ Code: http.StatusForbidden, JSON: jsonerror.Forbidden("user does not belong to room"), } } membership, err := ev.Membership() - if err != nil || membership != "join" { + if err != nil { + util.GetLogger(ctx).WithError(err).Error("Member event isn't valid") + e := jsonerror.InternalServerError() + return &e + } + if membership != gomatrixserverlib.Join { return &util.JSONResponse{ Code: http.StatusForbidden, JSON: jsonerror.Forbidden("user does not belong to room"), |