Fix linting

Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
Cnly 2019-06-25 22:22:03 +08:00
parent b896fdc537
commit 55a4e6061a
2 changed files with 12 additions and 14 deletions

View file

@ -272,7 +272,6 @@ func (d *SyncServerDatasource) addPDUDeltaToResponse(
} }
func (d *SyncServerDatasource) addTypingDeltaToResponse( func (d *SyncServerDatasource) addTypingDeltaToResponse(
ctx context.Context,
since int64, since int64,
joinedRoomIDs []string, joinedRoomIDs []string,
res *types.Response, res *types.Response,
@ -308,7 +307,6 @@ func (d *SyncServerDatasource) addTypingDeltaToResponse(
// addEDUDeltaToResponse adds updates for each type of EDUs since fromPos if // addEDUDeltaToResponse adds updates for each type of EDUs since fromPos if
// the position for that type of EDU in toPos is not 0. // the position for that type of EDU in toPos is not 0.
func (d *SyncServerDatasource) addEDUDeltaToResponse( func (d *SyncServerDatasource) addEDUDeltaToResponse(
ctx context.Context,
fromPos, toPos types.SyncPosition, fromPos, toPos types.SyncPosition,
joinedRoomIDs []string, joinedRoomIDs []string,
res *types.Response, res *types.Response,
@ -316,7 +314,7 @@ func (d *SyncServerDatasource) addEDUDeltaToResponse(
if toPos.TypingPosition != 0 { if toPos.TypingPosition != 0 {
err = d.addTypingDeltaToResponse( err = d.addTypingDeltaToResponse(
ctx, fromPos.TypingPosition, joinedRoomIDs, res, fromPos.TypingPosition, joinedRoomIDs, res,
) )
} }
@ -352,7 +350,7 @@ func (d *SyncServerDatasource) IncrementalSync(
} }
err = d.addEDUDeltaToResponse( err = d.addEDUDeltaToResponse(
ctx, fromPos, toPos, joinedRoomIDs, res, fromPos, toPos, joinedRoomIDs, res,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -455,7 +453,7 @@ func (d *SyncServerDatasource) CompleteSync(
// Use a zero value SyncPosition for fromPos so all EDU states are added. // Use a zero value SyncPosition for fromPos so all EDU states are added.
err = d.addEDUDeltaToResponse( err = d.addEDUDeltaToResponse(
ctx, types.SyncPosition{}, toPos, joinedRoomIDs, res, types.SyncPosition{}, toPos, joinedRoomIDs, res,
) )
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -99,17 +99,11 @@ func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, roomID string, userID
} }
} }
for _, toNotifyUserID := range userIDs { n.wakeupUsers(userIDs, pos)
n.wakeupUser(toNotifyUserID, pos)
}
} else if roomID != "" { } else if roomID != "" {
for _, userID := range n.joinedUsers(roomID) { n.wakeupUsers(n.joinedUsers(roomID), pos)
n.wakeupUser(userID, pos)
}
} else if len(userIDs) > 0 { } else if len(userIDs) > 0 {
for _, userID := range userIDs { n.wakeupUsers(userIDs, pos)
n.wakeupUser(userID, 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) { func (n *Notifier) wakeupUser(userID string, newPos types.SyncPosition) {
stream := n.fetchUserStream(userID, false) stream := n.fetchUserStream(userID, false)
if stream == nil { if stream == nil {