Commit 066cd7e0 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Improve handling of blocked user list when importing friends from Facebook.

parent 8ed4f769
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+11 −3
Original line number Diff line number Diff line
@@ -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)