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(
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

View file

@ -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 {