Beispiel #1
0
    def delete(self):
        # 친구 요청 취소
        receiver_id = request.form.get('receiver_id')

        FriendRequestsModel.objects(requester_id=current_identity, receiver_id=receiver_id).first().delete()

        return '', 200
Beispiel #2
0
    def post(self):
        # 친구 요청
        receiver_id = request.form.get('receiver_id')

        if FriendRequestsModel.objects(requester_id=current_identity, receiver_id=receiver_id):
            return '', 204
        else:
            FriendRequestsModel(requester_id=current_identity, receiver_id=receiver_id).save()

            return '', 201
Beispiel #3
0
    def post(self):
        # 친구 수락
        requester_id = request.form.get('requester_id')

        FriendRequestsModel.objects(requester_id=requester_id, receiver_id=current_identity).first().delete()

        friends = AccountModel.objects(id=current_identity).first().friends
        friends.append(requester_id)

        AccountModel.objects(id=current_identity).first().update(friends=friends)

        return '', 201
Beispiel #4
0
    def get(self):
        # 친구요청 목록
        friend_requests = FriendRequestsModel.objects(receiver_id=current_identity)

        if friend_requests:
            return [friend_request.requester_id for friend_request in friend_requests], 200
        else:
            return '', 204
Beispiel #5
0
    def get(self):
        id = request.args.get('id')

        user_data = AccountModel.objects(id=id).first()
        friend_requested = True if FriendRequestsModel.objects(
            requester_id=current_identity, receiver_id=id) else None

        if not user_data:
            return '', 204
        else:
            return {
                'id': id,
                'email': user_data.email,
                'phone': user_data.phone,
                'name': user_data.name,
                'friend_requested': friend_requested
            }