예제 #1
0
파일: Chat.py 프로젝트: alberto64/Quacker
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)
예제 #2
0
파일: Chat.py 프로젝트: alberto64/Quacker
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)
예제 #3
0
파일: Chat.py 프로젝트: alberto64/Quacker
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)
예제 #4
0
파일: Chat.py 프로젝트: alberto64/Quacker
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