def delete(self, request_id): try: self._validate_request_id(request_id) friend_request = FriendRequestModel.get_friend_request(request_id) self._validate_request_participant(friend_request) friend_request = FriendRequestModel.remove_friend_request( request_id) return self._get_friends_requests_response(friend_request) except NoFriendRequestFoundException as e: return ErrorHandler.create_error_response(str(e), 404) except UserMismatchException as e: return ErrorHandler.create_error_response(str(e), 409) except DBConnectionError as e: return ErrorHandler.create_error_response(str(e), 500)
def _accept_friend_request(self, request_id): friend_request = FriendRequestModel.remove_friend_request(request_id) friend_request.pop('_id') friend_res = FriendController() friend = friend_res.create_friendship(friend_request) return friend