示例#1
0
 def removeMember(self, cid, uid):
     result = ChatDAO()
     if not result.getChatByID(cid):
         return jsonify(Error="Chat not found."), 404
     else:
         result.removeMember(cid, uid)
         return jsonify(DeleteStatus="OK"), 200
示例#2
0
 def chatOwnerId(self, cid):
     dao = ChatDAO()
     row = dao.getChatByID(cid)
     if not row:
         return jsonify(Error="Chat Not Found"), 404
     else:
         user = self.build_owner_dict(row)
         return jsonify(User=user)
示例#3
0
 def getChatByID(self, cgid):
     dao = ChatDAO()
     result = dao.getChatByID(cgid)
     mapped_result = []
     if not result:
         return jsonify(Error="Not Found"), 404
     for r in result:
         mapped_result.append(self.mapToDict(r))
     return jsonify(Chat=mapped_result)
示例#4
0
 def removeChat(self, cID, ownerID):
     result = ChatDAO()
     user = UsersDAO()
     if not result.getChatByID(cID):
         return jsonify(Error="Chat not found."), 404
     else:
         print(ownerID, user.chatOwner(cID)[0])
         if ownerID == user.chatOwner(cID)[0]:
             print(ownerID, user.chatOwner(cID))
             result.delete(cID)
             return jsonify(DeleteStatus="OK"), 200
         else:
             return jsonify(Error="Not chat admin"), 404