diff --git a/syncapi/storage/syncserver.go b/syncapi/storage/syncserver.go index 46bcbf550..f77898e6f 100644 --- a/syncapi/storage/syncserver.go +++ b/syncapi/storage/syncserver.go @@ -272,7 +272,6 @@ func (d *SyncServerDatasource) addPDUDeltaToResponse( } func (d *SyncServerDatasource) addTypingDeltaToResponse( - ctx context.Context, since int64, joinedRoomIDs []string, res *types.Response, @@ -308,7 +307,6 @@ func (d *SyncServerDatasource) addTypingDeltaToResponse( // addEDUDeltaToResponse adds updates for each type of EDUs since fromPos if // the position for that type of EDU in toPos is not 0. func (d *SyncServerDatasource) addEDUDeltaToResponse( - ctx context.Context, fromPos, toPos types.SyncPosition, joinedRoomIDs []string, res *types.Response, @@ -316,7 +314,7 @@ func (d *SyncServerDatasource) addEDUDeltaToResponse( if toPos.TypingPosition != 0 { err = d.addTypingDeltaToResponse( - ctx, fromPos.TypingPosition, joinedRoomIDs, res, + fromPos.TypingPosition, joinedRoomIDs, res, ) } @@ -352,7 +350,7 @@ func (d *SyncServerDatasource) IncrementalSync( } err = d.addEDUDeltaToResponse( - ctx, fromPos, toPos, joinedRoomIDs, res, + fromPos, toPos, joinedRoomIDs, res, ) if err != nil { return nil, err @@ -455,7 +453,7 @@ func (d *SyncServerDatasource) CompleteSync( // Use a zero value SyncPosition for fromPos so all EDU states are added. err = d.addEDUDeltaToResponse( - ctx, types.SyncPosition{}, toPos, joinedRoomIDs, res, + types.SyncPosition{}, toPos, joinedRoomIDs, res, ) if err != nil { return nil, err diff --git a/syncapi/sync/notifier.go b/syncapi/sync/notifier.go index 23fbd0852..48527555b 100644 --- a/syncapi/sync/notifier.go +++ b/syncapi/sync/notifier.go @@ -99,17 +99,11 @@ func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, roomID string, userID } } - for _, toNotifyUserID := range userIDs { - n.wakeupUser(toNotifyUserID, pos) - } + n.wakeupUsers(userIDs, pos) } else if roomID != "" { - for _, userID := range n.joinedUsers(roomID) { - n.wakeupUser(userID, pos) - } + n.wakeupUsers(n.joinedUsers(roomID), pos) } else if len(userIDs) > 0 { - for _, userID := range userIDs { - n.wakeupUser(userID, pos) - } + n.wakeupUsers(userIDs, pos) } } @@ -163,6 +157,12 @@ func (n *Notifier) setUsersJoinedToRooms(roomIDToUserIDs map[string][]string) { } } +func (n *Notifier) wakeupUsers(userIDs []string, newPos types.SyncPosition) { + for _, userID := range userIDs { + n.wakeupUser(userID, newPos) + } +} + func (n *Notifier) wakeupUser(userID string, newPos types.SyncPosition) { stream := n.fetchUserStream(userID, false) if stream == nil {