Esempio n. 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)
Esempio n. 2
0
class Messages(Resource):
    def __init__(self):
        self.handler = MessageHandler()

    def get(self):
        messages = self.handler.get_all_messages()
        return jsonify(messages=messages)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 8
0
def getReplyString(repID):
    return MessageHandler().getReplyForDisplay(repID)
Esempio n. 9
0
def getMessageThatReplied(mid):
    return MessageHandler().getMessageThatReplied(mid)
Esempio n. 10
0
def trending_topics():
    """
    Gets trending hashtags from database
    :return: JSON
    """
    return MessageHandler().get_trending_hashtags(), 200
Esempio n. 11
0
def messagesByUserId(uid):
    return MessageHandler().searchMessagesByUserId(uid)
Esempio n. 12
0
def messagesByChatName():
    if request.method == 'GET':
        return MessageHandler().getAllMessages()
Esempio n. 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())
Esempio n. 14
0
def messagesFromGroupId(gid):
    return MessageHandler().searchMessagesByGroupId(gid)
Esempio n. 15
0
def num_of_dislikes():
    """
    Gets number of dislikes per day from database
    :return: JSON
    """
    return MessageHandler().get_num_dislikes_daily(), 200
Esempio n. 16
0
def num_of_posts():
    """
    Gets number of messages posted per day from database
    :return: JSON
    """
    return MessageHandler().get_num_messages_daily(), 200
Esempio n. 17
0
 def get(self, mid):
     dislikers = MessageHandler().get_dislikers(mid)
     return jsonify(dislikers=dislikers, dislikes=len(dislikers))
Esempio n. 18
0
def repliesOfMessage(mid):
    return MessageHandler().getRepliesForMessage(mid)
Esempio n. 19
0
 def __init__(self):
     self.handler = MessageHandler()
Esempio n. 20
0
def getMessageBymsgId(mid):
    return MessageHandler().getMessageByMsgId(mid)