Example #1
0
def getAllActiveChats():
    result = dao.getAllActiveChats()
    if not result:
        return jsonify(Error="No Chats Found")
    mapped_result = []
    for r in result:
        mapped_result.append(Dic.build_chat_dict(r))
    return jsonify(Chats=mapped_result)
Example #2
0
def getChatAsAdmin(uID):
    result = dao.getChatsAsAdmin(uID)
    if not result:
        return jsonify(Error="No Chats Found")
    mapped_result = []
    for r in result:
        mapped_result.append(Dic.build_chat_dict(r))
    return jsonify(AdminChats=mapped_result)
Example #3
0
def getChatByID(cID):
    # This method will return the determined chat by its ID
    desired_chat = dao.getChatByID(cID)
    if not desired_chat:
        return jsonify(Error=" Chat not found"), 404

    chat = Dic.build_chat_dict(desired_chat)
    return jsonify(Chat=chat)
Example #4
0
def getChatByUserID(uID):
    # This method will return the chats on which the user are part of
    chats = dao.getChatByUserID(uID)
    if not chats:
        return jsonify(Error="No Chats Found")
    result_list = []
    for row in chats:
        result = Dic.build_chat_dict(row)
        result_list.append(result)
    return jsonify(Chats=result_list)
Example #5
0
def getGroupChats():
    groupChats = dao.getGroupChats()
    if not groupChats:
        return jsonify(Error= "No group chats in the system")
    result_list = []

    for row in groupChats:
        results = Dic.build_chat_dict(row)
        print(row)
        result_list.append(results)
    return jsonify(GroupChats = result_list)
Example #6
0
def getAllChats():
    # This method will return all the chats
    chat_lists = dao.getAllChats()
    if not chat_lists:
        return jsonify(Error="No Chats Found")
    result_list = []

    for row in chat_lists:
        result = Dic.build_chat_dict(row)
        result_list.append(result)
    return jsonify(Chat=result_list)