Skip to content

Commit

Permalink
Improve handling of blocked user list when importing friends from Fac…
Browse files Browse the repository at this point in the history
…ebook.
  • Loading branch information
zyro committed Aug 1, 2018
1 parent 8ed4f76 commit 066cd7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr

### Fixed
- Runtime module loading now correctly handles paths on non-UNIX environments.
- Correctly handle blocked user list when importing friends from Facebook.

## [2.0.2] - 2018-07-09
### Added
Expand Down
14 changes: 11 additions & 3 deletions server/core_authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,25 @@ func importFacebookFriends(logger *zap.Logger, db *sql.DB, messageRouter Message
}
return err
}
defer rows.Close()

var id string
possibleFriendIDs := make([]uuid.UUID, 0)
for rows.Next() {
position := time.Now().UTC().UnixNano()
err = rows.Scan(&id)
if err != nil {
// Error scanning the ID, try to skip this user and move on.
continue
}
friendID := uuid.FromStringOrNil(id)
friendID, err := uuid.FromString(id)
if err != nil {
continue
}
possibleFriendIDs = append(possibleFriendIDs, friendID)
}
rows.Close()

for _, friendID := range possibleFriendIDs {
position := time.Now().UTC().UnixNano()

var r *sql.Rows
r, err = tx.Query("SELECT state FROM user_edge WHERE source_id = $1 AND destination_id = $2 AND state = 3", userID, friendID)
Expand Down

0 comments on commit 066cd7e

Please sign in to comment.