Esempio n. 1
0
 def getGroupChatNameById(self, gid):
     dao = GroupChatDAO()
     result = dao.getGroupChatNameById(gid)
     if (result == None):
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         mapped_result.append(self.mapToDictIdtoName(result))
         return jsonify(GroupChats=mapped_result)
Esempio n. 2
0
 def getGroupChatByOwner(self, uid):
     dao = GroupChatDAO()
     result = dao.getGroupChatByOwner(uid)
     if (result == None):
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDictInfoByOwner(r))
         return jsonify(GroupChatsByOwner=mapped_result)
Esempio n. 3
0
 def getGroupChatInfoByName(self, name):
     dao = GroupChatDAO()
     result = dao.getGroupChatInfoByName(name)
     if (result == None):
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDictInfoByName(r))
         return jsonify(GroupChats=mapped_result)
Esempio n. 4
0
 def getAllGroupChats(self):
     dao = GroupChatDAO()
     result = dao.getAllGroupChats()
     if result == None:
         return jsonify(Error="NOT FOUND"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(GroupChats=mapped_result)
Esempio n. 5
0
 def insertParticipant(self, form):
     dao = GroupChatDAO()
     if len(form) != 3:
         return jsonify(Error="Malformed insert request"), 400
     else:
         GID = form['GID']
         UID = form['UID']
         CUID = form['CUID']
         if GID and UID:
             validate = dao.validateContact(UID, CUID)
             if (validate == None):
                 return jsonify(Error="Not a Contact"), 404
             row = dao.insertParticipant(GID, CUID)
             if row == None:
                 return jsonify(Error="Invalid Insert"), 404
             else:
                 #result = self.insert_NewChatGroup_dict(GID, UID)
                 return jsonify(User="******")
         else:
             return jsonify(
                 Error="Unexpected attributes in insert request"), 400
Esempio n. 6
0
 def insertNewChatGroup(self, form):
     dao = GroupChatDAO()
     if len(form) != 2:
         return jsonify(Error="Malformed insert request"), 400
     else:
         GName = form['GName']
         GCDate = datetime.datetime.today().strftime('%d-%m-%Y')
         UID = form['UID']
         if GName and GCDate and UID:
             row = dao.insertNewChatGroup(GName, GCDate, UID)
             if row == None:
                 return jsonify(Error="Invalid Insert"), 404
             else:
                 GID = row
                 print('GID : ', GID)
                 dao.insertParticipant(GID, UID)
                 result = self.insert_NewChatGroup_dict(GName, GCDate, UID)
                 return jsonify(User=result)
         else:
             return jsonify(
                 Error="Unexpected attributes in insert request"), 400