예제 #1
0
    def post(self, entity):
        try:
            data = json.loads(request.data)
        except json.JSONDecodeError as e:
            raise APIBadRequest(str(e))
        new_post = Post()
        new_post.entity = entity
        new_post.schema = data['schema']
        new_post.content = data['content']

        new_post.save()

        for to_notify in entity.followers:
            notification_link = follow.get_notification_link(to_notify)
            requests.post(notification_link, data=jsonify(new_post.to_json()))
            #TODO Handle failled notifications somehow

        return jsonify(new_post.to_json()), 200
예제 #2
0
파일: entity.py 프로젝트: pytent/pytentd
    def post(self, entity):
        try:
            data = json.loads(request.data)
        except json.JSONDecodeError as e:
            raise APIBadRequest(str(e))
        new_post = Post()
        new_post.entity = entity
        new_post.schema = data["schema"]
        new_post.content = data["content"]

        new_post.save()

        for to_notify in entity.followers:
            notification_link = follow.get_notification_link(to_notify)
            requests.post(notification_link, data=jsonify(new_post.to_json()))
            # TODO Handle failled notifications somehow

        return jsonify(new_post.to_json()), 200