diff --git a/CHANGELOG.md b/CHANGELOG.md index 072c4938bdce624b23c90d2f7b9e2b7feb64369c..a0f10155c9e706c773eb96c97f057820a30dfe1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/server/core_authenticate.go b/server/core_authenticate.go index 8ee43b12dea55c9e62e73702caad4422f5eff88c..f375f97b91173b49a2d4f811c5d011b450f22e96 100644 --- a/server/core_authenticate.go +++ b/server/core_authenticate.go @@ -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)