Esempio n. 1
0
def getChatAsMember(uID):
    result = dao.getChatAsMember(uID)
    if not result:
        return jsonify(Error="No Chats Found")
    mapped_result = []
    for r in result:
        mapped_result.append(Dic.build_participants_dict(r))
    return jsonify(MemberChats=mapped_result)
Esempio n. 2
0
def getParticipantsByChatID(cID):
    # This method returns the list of participants in a determined chat
    chat_participants = dao.getChatParticipants(cID)
    if not chat_participants:
        return jsonify(Error="No Participants Found")
    result_list = []
    for row in chat_participants:
        result = Dic.build_participants_dict(row)
        result_list.append(result)
    return jsonify(Participants=result_list)
Esempio n. 3
0
def getALlParticipants():
    # This method will return all the participants on the application
    participants = dao.getAllParticipants()
    if not participants:
        return jsonify(Error="No Participants Found")
    result_list = []
    for row in participants:
        result = Dic.build_participants_dict(row)
        result_list.append(result)
    return jsonify(Participants=result_list)
Esempio n. 4
0
def insertParticipant(json):
    if len(json) != 3:
        return jsonify(Error = "Malformed post request, missing or extra data")

    else:
        cid = json['cid']
        uid = json['uid']
        contact = json['contact']

        if cid and uid and contact:
            test = dao.getChatParticipant(cid, contact)
            if test:
                return jsonify(Error="User already a participant")
            ptime = dao.insertParticipant(cid,uid,contact)
            print(ptime)

            if ptime:
                result = Dic.build_participants_dict([cid,uid,ptime[0]])
                return jsonify(Participant = result)
            else:
                return jsonify(Error = "Could not insert the participant")
        else:
            return jsonify(Error='Unexpected attributes in post request'), 400