aboutsummaryrefslogtreecommitdiff
path: root/syncapi/routing
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-10-27 14:18:22 +0200
committerGitHub <noreply@github.com>2022-10-27 14:18:22 +0200
commita169a9121aa6b2ff3e3fba6ec9777227e349300f (patch)
tree9b3467638ba7633f3c85c317012e8d8815c420e0 /syncapi/routing
parentfa96811e64302cad7d51b6c20ebbc8abd5105af4 (diff)
Fix /members (#2837)
Fixes a bug introduced in #2827, where the SyncAPI might not have all requested eventIDs, resulting in too few members returned.
Diffstat (limited to 'syncapi/routing')
-rw-r--r--syncapi/routing/memberships.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/syncapi/routing/memberships.go b/syncapi/routing/memberships.go
index c9acc5d2..05c7deef 100644
--- a/syncapi/routing/memberships.go
+++ b/syncapi/routing/memberships.go
@@ -76,6 +76,13 @@ func GetMemberships(
}
}
+ if joinedOnly && !queryRes.IsInRoom {
+ return util.JSONResponse{
+ Code: http.StatusForbidden,
+ JSON: jsonerror.Forbidden("You aren't a member of the room and weren't previously a member of the room."),
+ }
+ }
+
db, err := syncDB.NewDatabaseSnapshot(req.Context())
if err != nil {
return jsonerror.InternalServerError()
@@ -102,19 +109,15 @@ func GetMemberships(
return jsonerror.InternalServerError()
}
- result, err := db.Events(req.Context(), eventIDs)
- if err != nil {
- util.GetLogger(req.Context()).WithError(err).Error("db.Events failed")
+ qryRes := &api.QueryEventsByIDResponse{}
+ if err := rsAPI.QueryEventsByID(req.Context(), &api.QueryEventsByIDRequest{EventIDs: eventIDs}, qryRes); err != nil {
+ util.GetLogger(req.Context()).WithError(err).Error("rsAPI.QueryEventsByID failed")
return jsonerror.InternalServerError()
}
+ result := qryRes.Events
+
if joinedOnly {
- if !queryRes.IsInRoom {
- return util.JSONResponse{
- Code: http.StatusForbidden,
- JSON: jsonerror.Forbidden("You aren't a member of the room and weren't previously a member of the room."),
- }
- }
var res getJoinedMembersResponse
res.Joined = make(map[string]joinedMember)
for _, ev := range result {