mirror of
https://github.com/matrix-org/dendrite
synced 2024-12-14 05:33:49 +01:00
Reduce the number of allocations made by localRoomMembers
when consuming stream events for push notifications (#2324)
This commit is contained in:
parent
f7109de500
commit
16e2d243fc
3 changed files with 4 additions and 1 deletions
|
@ -128,6 +128,8 @@ type QueryMembershipForUserResponse struct {
|
||||||
type QueryMembershipsForRoomRequest struct {
|
type QueryMembershipsForRoomRequest struct {
|
||||||
// If true, only returns the membership events of "join" membership
|
// If true, only returns the membership events of "join" membership
|
||||||
JoinedOnly bool `json:"joined_only"`
|
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
|
// ID of the room to fetch memberships from
|
||||||
RoomID string `json:"room_id"`
|
RoomID string `json:"room_id"`
|
||||||
// Optional - ID of the user sending the request, for checking if the
|
// Optional - ID of the user sending the request, for checking if the
|
||||||
|
|
|
@ -220,7 +220,7 @@ func (r *Queryer) QueryMembershipsForRoom(
|
||||||
if request.Sender == "" {
|
if request.Sender == "" {
|
||||||
var events []types.Event
|
var events []types.Event
|
||||||
var eventNIDs []types.EventNID
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("r.DB.GetMembershipEventNIDsForRoom: %w", err)
|
return fmt.Errorf("r.DB.GetMembershipEventNIDsForRoom: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ func (s *OutputStreamEventConsumer) localRoomMembers(ctx context.Context, roomID
|
||||||
req := &rsapi.QueryMembershipsForRoomRequest{
|
req := &rsapi.QueryMembershipsForRoomRequest{
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
JoinedOnly: true,
|
JoinedOnly: true,
|
||||||
|
LocalOnly: true,
|
||||||
}
|
}
|
||||||
var res rsapi.QueryMembershipsForRoomResponse
|
var res rsapi.QueryMembershipsForRoomResponse
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue