Пример #1
0
class LikeChatMessage(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self, mid):
        likers = self.handler.get_likers(mid)
        return jsonify(likers=likers, likes=len(likers))

    @jwt_required
    def post(self, mid):
        message = self.handler.like_message(mid)
        return jsonify(message=message)
Пример #2
0
class Messages(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self):
        messages = self.handler.get_all_messages()
        return jsonify(messages=messages)
Пример #3
0
class Message(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self, mid):
        message = self.handler.get_message(mid)
        return jsonify(message=message)
Пример #4
0
def num_of_replies_photo(pid):
    """
    Gets number of photo replies per day for the given photo id
    :param pid: int
    :return: JSON
    """
    return MessageHandler().get_num_replies_photo(pid)
Пример #5
0
def num_of_dislikes_photos(pid):
    """
    Gets number of dislikes for the given photo id
    :param pid: int
    :return: JSON
    """
    return MessageHandler().get_num_dislikes_photo(pid)
Пример #6
0
class DislikeChatMessage(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self, mid):
        dislikers = MessageHandler().get_dislikers(mid)
        return jsonify(dislikers=dislikers, dislikes=len(dislikers))

    @jwt_required
    def post(self, mid):
        message = self.handler.dislike_message(mid)
        return jsonify(message=message)
Пример #7
0
class ReplyChatMessage(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self, mid):
        replies = self.handler.get_replies(mid)
        return jsonify(replies=replies)

    @jwt_required
    def post(self, mid):
        parser = reqparse.RequestParser()
        parser.add_argument('message', help=HELP_TEXT, required=True)
        parser.add_argument('cid', help=HELP_TEXT, required=True)
        data = parser.parse_args()
        data['img'] = None
        if 'img' in request.files and request.files['img']:
            data['img'] = request.files['img']
        response, status = ChatHandler().reply_chat_message(data, mid)
        return app.response_class(response=response,
                                  status=status,
                                  mimetype='application/json')
Пример #8
0
def getReplyString(repID):
    return MessageHandler().getReplyForDisplay(repID)
Пример #9
0
def getMessageThatReplied(mid):
    return MessageHandler().getMessageThatReplied(mid)
Пример #10
0
def trending_topics():
    """
    Gets trending hashtags from database
    :return: JSON
    """
    return MessageHandler().get_trending_hashtags(), 200
Пример #11
0
def messagesByUserId(uid):
    return MessageHandler().searchMessagesByUserId(uid)
Пример #12
0
def messagesByChatName():
    if request.method == 'GET':
        return MessageHandler().getAllMessages()
Пример #13
0
def messagesOfUserFromGroup(uid, gid):
    if request.method == 'GET':
        return MessageHandler().searchMessagesOfUserFromGroup(uid, gid)
    elif request.method == 'POST':
        return MessageHandler().postMessage(uid, gid, request.get_json())
Пример #14
0
def messagesFromGroupId(gid):
    return MessageHandler().searchMessagesByGroupId(gid)
Пример #15
0
def num_of_dislikes():
    """
    Gets number of dislikes per day from database
    :return: JSON
    """
    return MessageHandler().get_num_dislikes_daily(), 200
Пример #16
0
def num_of_posts():
    """
    Gets number of messages posted per day from database
    :return: JSON
    """
    return MessageHandler().get_num_messages_daily(), 200
Пример #17
0
 def get(self, mid):
     dislikers = MessageHandler().get_dislikers(mid)
     return jsonify(dislikers=dislikers, dislikes=len(dislikers))
Пример #18
0
def repliesOfMessage(mid):
    return MessageHandler().getRepliesForMessage(mid)
Пример #19
0
 def __init__(self):
     self.handler = MessageHandler()
Пример #20
0
def getMessageBymsgId(mid):
    return MessageHandler().getMessageByMsgId(mid)