Beispiel #1
0
 def createGroup(self, json):
     dao = GroupDAO()
     chat_name = json['chat_name']
     user_id = json['user_id']
     chat_group_id = dao.createGroup(chat_name, user_id)
     dao.addContactTogroup(chat_group_id, user_id)  #add user to group
     return jsonify(chat_group_id), 201
Beispiel #2
0
 def getGroupByGroupID(self, gID):
     dao = GroupDAO()
     result = dao.getGroupByGroupID(gID)
     if not result:
         return jsonify(Error="Not found"), 404
     mapped_result = mapGroupToDict(result)
     return jsonify(mapped_result)
Beispiel #3
0
 def removeMember(self, chat_group_id, json):
     dao = GroupDAO()
     user_id = json['user_id']
     if user_id:
         result = dao.removeContactFromGroup(chat_group_id, user_id)
         return jsonify(result), 200
     else:
         return jsonify(Error="Unexpected attributes in post request"), 400
Beispiel #4
0
 def getAllGroups(self):
     dao = GroupDAO()
     result = dao.getAllGroups()
     if not result:
         return jsonify(Error="Not found"), 404
     mapped_result = []
     for r in result:
         mapped_result.append(mapGroupToDict(r))
     return jsonify(mapped_result)
Beispiel #5
0
 def getGroupMembersByGroupID(self, gID):
     dao = GroupDAO()
     result = dao.getGroupMembersByGroupID(gID)
     if not result:
         return jsonify(Error="Not found"), 404
     mapped_result = []
     for r in result:
         mapped_result.append(mapUserToDict(r))
     return jsonify(mapped_result)
Beispiel #6
0
 def removeMember(self, gID, json):
     dao = GroupDAO()
     if len(json) != 1:
         return jsonify(Error="Malformed post request"), 400
     else:
         contactid = json['contactid']
         if contactid:
             result = dao.removeContactFromGroup(gID, contactid)
             return jsonify(result), 201
         else:
             return jsonify(
                 Error="Unexpected attributes in post request"), 400
Beispiel #7
0
 def deleteGroup(self, json):
     dao = GroupDAO()
     if len(json) != 2:
         return jsonify(Error="Malformed post request"), 400
     else:
         groupId = json['groupId']
         ownerId = json['ownerid']
         if groupId and ownerId:
             result = dao.deleteGroup(groupId, ownerId)
             return jsonify(result), 201
         else:
             return jsonify(
                 Error="Unexpected attributes in post request"), 400
Beispiel #8
0
 def searchGroup(self, args):
     groupname = args.get("groupname")
     dao = GroupDAO()
     if groupname:
         result = dao.getGroupByName(groupname)
     return jsonify(result)
Beispiel #9
0
 def getAllgroups(self):
     dao = GroupDAO()
     result = dao.getAllGroups()
     return jsonify(Users=result)
Beispiel #10
0
 def getMembersByGroupID(self, gID):
     dao = GroupDAO()
     result = dao.getMembersByGroupID(gID)
     return jsonify(Members=result)
Beispiel #11
0
 def getGroupOwnerByID(self, gID):
     dao = GroupDAO()
     result = dao.getGroupOwnerByID(gID)
     return jsonify(Owner=result)
Beispiel #12
0
 def getGroupById(self, gID):
     dao = GroupDAO()
     result = dao.getGroupByID(gID)
     return jsonify(User=result)
Beispiel #13
0
 def deleteGroup(self, json):
     dao = GroupDAO()
     chat_group_id = json['chat_group_id']
     user_id = json['user_id']
     result = dao.deleteGroup(chat_group_id, user_id)
     return jsonify(result), 201