Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Checks for remote friend status
- if request.user.is_authenticated():
- current_profile = Profile.objects.get(user_id = request.user.id)
- follow_qs = Follow.objects.filter(from_profile_id=current_profile.id).filter(status='PENDING')
- for follow in follow_qs:
- #check each follow to_profile to see if they are remote or local
- to_profile_host = follow.to_profile_id.host
- host_port = to_profile_host.strip("http://").split(":")
- port = host_port[1]
- if port != "8000":
- host = Host.objects.filter( Q(host_url__icontains=port) ).first()
- friend_response = host.get_friend_response(str(current_profile.uuid), str(follow.to_profile_id.uuid))
- if friend_response['friends'].upper() == "YES" or friend_response['friends'] == True:
- current_profile.friends.add(follow.to_profile_id)
- current_profile.save()
- follow.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement