check if any friendship exists with another user
10192
def friendshiped_with?(user)
      (friend_ids + inverse_friend_ids + pending_friend_ids + pending_inverse_friend_ids + blocked_friend_ids).include?(user.id)
    end
203836
def relation_exists(self, parent, child, relation_type):
        """"""
        return PIDRelation.query.filter_by(
            child_pid_id=child.id,
            parent_pid_id=parent.id,
            relation_type=relation_type).count() > 0
464155
def get_friends(self, query):
        
        # Connecting to the API
        api = self._connectToAPI()

        # Verifying the limits of the API
        self._rate_limit_status(api=api, mode="get_friends")

        # Making the call to the API
        try:
            friends_ids = api.friends_ids(query)
        except:
            return []

        """res = []
        # Extracting the information from each profile
        for a in aux:
            us= self.getUser(a)
            res.append(self._processUser(us))"""

        return friends_ids
67939
function FoundFriend (params) {
  var self = this
  if (!(self instanceof FoundFriend)) return new FoundFriend(params)

  self.displayName = params['display']
  self.username = params['name']
  self.isPrivate = !!params['type']
}
1111482
def blocked?(user)
      (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).include?(user.id) or user.blocked_pending_inverse_friend_ids.include?(self.id)
    end
554694
def invited_by?(user)
      user.friend_ids.include?(self.id) or user.pending_friend_ids.include?(self.id)
    end
196045
function is_followed_by_name( $target_name, $source_name = NULL )
	{
		$params = array();
		$params['target_screen_name'] = $target_name;

		if ( $source_name != NULL ) {
			$params['source_screen_name'] = $source_name;
		}

		return $this->oauth->get( 'friendships/show', $params );
	}
372952
def check_unique(self):
        """"""
        emails = yield self.view.values(key=self.email)
        user_id = getattr(self, 'id', None)
        users = {x for x in emails if x != user_id and x}

        if users:
            raise exceptions.ValidationError(
                "User with email '{}' already exists".format(self.email))
409092
def invited?(user)
      self.friend_ids.include?(user.id) or self.pending_friend_ids.include?(user.id)
    end
741329
public List<Friend> getFriends() {
		return getFriends(new Filter<Friend>() {

			public boolean accept(Friend e) {
				return true;
			}
		});
	}
664152
def get(self, request, provider=None):
        """"""
        # Get the social auth connections
        if USING_ALLAUTH:
            self.social_auths = request.user.socialaccount_set.all()
        else:
            self.social_auths = request.user.social_auth.all()
                
        self.social_friend_lists = []

        # if the user did not connect any social accounts, no need to continue
        if self.social_auths.count() == 0:
            if REDIRECT_IF_NO_ACCOUNT:
                return HttpResponseRedirect(REDIRECT_URL)
            return super(FriendListView, self).get(request)

        # for each social network, get or create social_friend_list
        self.social_friend_lists = SocialFriendList.objects.get_or_create_with_social_auths(self.social_auths)

        return super(FriendListView, self).get(request)
933096
function(userObjectId) {
        if (!userObjectId || !_.isString(userObjectId)) {
          throw new Error('Invalid user object id.');
        }
        var query = new AV.FriendShipQuery('_Follower');
        query._friendshipTag = 'follower';
        query.equalTo(
          'user',
          AV.Object.createWithoutData('_User', userObjectId)
        );
        return query;
      }
209983
function tokenExists(username, token, done) {
  return getTokenHashes(username, function(getTokensErr, hashes) {
    if (getTokensErr) {
      return done(getTokensErr);
    }

    if (!hashes || !hashes.length) {
      return done(null, false);
    }

    let index = 0;
    let found = false;

    async.until(() => found || (index >= hashes.length), function(next) {
      bcrypt.compare(token, hashes[index++].uuid, function(err, match) {
        found = match;
        return next(err);
      });
    }, (err) => done(err, found ? hashes[index - 1] : undefined));
  });
}
60740
def fetch_friend_ids(self, user):
        
        friends = self.fetch_friends(user)

        return [friend['ns1_email']['address']
                for friend in friends
                if 'ns1_email' in friend]
220084
function checknick(next) {
        if (args.nick) {
          userent.list$({ nick: args.nick }, function(err, users) {
            if (err) return done(err, { ok: false, user: user })
            for (var i = 0; i < users.length; i++) {
              var each = users[i]
              if (each.id !== user.id) {
                return done(null, {
                  ok: false,
                  why: 'nick-exists',
                  nick: args.nick
                })
              }
            }

            next()
          })
          return
        }
        next()
      }
883289
def friends(self):
        
        if self._friends is None:
            self.assert_bind_client()
            if self.friend_count > 0:
                self._friends = self.bind_client.get_athlete_friends(self.id)
            else:
                # Shortcut if we know there aren't any
                self._friends = []
        return self._friends
263863
def invite(user)
      return false if friendshiped_with?(user) or user == self or blocked?(user)
      pending_friend_ids << user.id
      user.pending_inverse_friend_ids << self.id
      self.save && user.save
    end