示例#1
0
 def undislike(self, mid, pid):
     """delete a like on a message"""
     dao = ReactionDAO()
     if not dao.getWhoDislikedById(mid, pid):
         return jsonify(Error="User not found."), 404
     else:
         dao.deleteDislike(mid, pid)
         return jsonify(DeleteStatus="OK"), 200
示例#2
0
 def dislike(self, mid, json):
     """Add a like on the message"""
     if len(json) != 1:
         return jsonify(Error="Malformed post request"), 400
     else:
         pid = json['pid']
         if pid:
             dao = ReactionDAO()
             if not dao.getWhoDislikedById(mid, pid):
                 mid = dao.insertDislike(mid, pid)
             else:
                 dao.deleteDislike(mid, pid)
             result = self.map_likes_dislikes_attributes(mid, pid)
             return jsonify(Message=result), 201
         else:
             return jsonify(Error="Unexpected attributes in post request"), 400