mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-13 23:31:34 +00:00
Fix /members (#2837)
Fixes a bug introduced in #2827, where the SyncAPI might not have all requested eventIDs, resulting in too few members returned.
This commit is contained in:
parent
fa96811e64
commit
a169a9121a
@ -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())
|
db, err := syncDB.NewDatabaseSnapshot(req.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
@ -102,19 +109,15 @@ func GetMemberships(
|
|||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := db.Events(req.Context(), eventIDs)
|
qryRes := &api.QueryEventsByIDResponse{}
|
||||||
if err != nil {
|
if err := rsAPI.QueryEventsByID(req.Context(), &api.QueryEventsByIDRequest{EventIDs: eventIDs}, qryRes); err != nil {
|
||||||
util.GetLogger(req.Context()).WithError(err).Error("db.Events failed")
|
util.GetLogger(req.Context()).WithError(err).Error("rsAPI.QueryEventsByID failed")
|
||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result := qryRes.Events
|
||||||
|
|
||||||
if joinedOnly {
|
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
|
var res getJoinedMembersResponse
|
||||||
res.Joined = make(map[string]joinedMember)
|
res.Joined = make(map[string]joinedMember)
|
||||||
for _, ev := range result {
|
for _, ev := range result {
|
||||||
|
Loading…
Reference in New Issue
Block a user