aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-04-06 10:43:54 +0100
committerGitHub <noreply@github.com>2022-04-06 10:43:54 +0100
commit16e2d243fc8f3d433a9d7f428e6f782065dc5e89 (patch)
treeb1e8b7463391319c03d16060c60f678e81647b0f
parentf7109de500d675855f9d63c1959f244d34096a4b (diff)
Reduce the number of allocations made by `localRoomMembers` when consuming stream events for push notifications (#2324)
-rw-r--r--roomserver/api/query.go2
-rw-r--r--roomserver/internal/query/query.go2
-rw-r--r--userapi/consumers/syncapi_streamevent.go1
3 files changed, 4 insertions, 1 deletions
diff --git a/roomserver/api/query.go b/roomserver/api/query.go
index 66e85f2f..8f84edcb 100644
--- a/roomserver/api/query.go
+++ b/roomserver/api/query.go
@@ -128,6 +128,8 @@ type QueryMembershipForUserResponse struct {
type QueryMembershipsForRoomRequest struct {
// If true, only returns the membership events of "join" membership
JoinedOnly bool `json:"joined_only"`
+ // If true, only returns the membership events of local users
+ LocalOnly bool `json:"local_only"`
// ID of the room to fetch memberships from
RoomID string `json:"room_id"`
// Optional - ID of the user sending the request, for checking if the
diff --git a/roomserver/internal/query/query.go b/roomserver/internal/query/query.go
index 471c6fb4..7e4d5668 100644
--- a/roomserver/internal/query/query.go
+++ b/roomserver/internal/query/query.go
@@ -220,7 +220,7 @@ func (r *Queryer) QueryMembershipsForRoom(
if request.Sender == "" {
var events []types.Event
var eventNIDs []types.EventNID
- eventNIDs, err = r.DB.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, request.JoinedOnly, false)
+ eventNIDs, err = r.DB.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, request.JoinedOnly, request.LocalOnly)
if err != nil {
return fmt.Errorf("r.DB.GetMembershipEventNIDsForRoom: %w", err)
}
diff --git a/userapi/consumers/syncapi_streamevent.go b/userapi/consumers/syncapi_streamevent.go
index da3cd393..34a67d2e 100644
--- a/userapi/consumers/syncapi_streamevent.go
+++ b/userapi/consumers/syncapi_streamevent.go
@@ -184,6 +184,7 @@ func (s *OutputStreamEventConsumer) localRoomMembers(ctx context.Context, roomID
req := &rsapi.QueryMembershipsForRoomRequest{
RoomID: roomID,
JoinedOnly: true,
+ LocalOnly: true,
}
var res rsapi.QueryMembershipsForRoomResponse