Exemple #1
0
 def getChatMedia(self, chat_id):
     dao = ChatDAO()
     mediaList = dao.getChatMedia(chat_id)
     resultlist = []
     for row in mediaList:
         result = self.build_chat_media_dict(row)
         resultlist.append(result)
     return jsonify(Media=resultlist)
Exemple #2
0
 def getChatPost(self, chat_id):
     dao = ChatDAO()
     postlist = dao.getChatPost(chat_id)
     resultlist = []
     for row in postlist:
         result = self.build_chat_post_dict(row)
         resultlist.append(result)
     return jsonify(Post=resultlist)
Exemple #3
0
 def getChatAdmin(self, chat_id):
     dao = ChatDAO()
     userList = dao.getChatAdmin(chat_id)
     resultlist = []
     for row in userList:
         result = self.build_chat_user_dict(row)
         resultlist.append(result)
     return jsonify(User=resultlist)
Exemple #4
0
 def getChatParticipant(self, chat_id):
     dao = ChatDAO()
     participantlist = dao.getChatParticipant(chat_id)
     resultlist = []
     for row in participantlist:
         result = self.build_chat_participant_dict(row)
         resultlist.append(result)
     return jsonify(Participant=resultlist)
Exemple #5
0
 def getChatById(self, chat_id):
     dao = ChatDAO()
     chatlist = dao.getChatById(chat_id)
     resultlist = []
     for row in chatlist:
         result = self.build_chat_name_dict(row)
         resultlist.append(result)
     return jsonify(Chat=resultlist)
Exemple #6
0
 def getAllChat(self):
     dao = ChatDAO()
     chatlist = dao.getAllChat()
     resultlist = []
     for row in chatlist:
         result = self.build_chat_name_dict(row)
         resultlist.append(result)
     return jsonify(Chat_Name=resultlist)
 def getAllChats(self):
     dao = ChatDAO()
     result = dao.getAllChats()
     if not result:
         return jsonify(Error="No chats"), 404
     mapped_result = []
     for r in result:
         mapped_result.append(self.mapToDict(r))
     return jsonify(Chats=mapped_result)
 def getOwner(self, cid):
     dao = ChatDAO()
     result = dao.getOwnerOfChat(cid)
     if not result:
         return jsonify(Error="No chat with that ID"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapOwnerToDict(r))
         return jsonify(Owner=mapped_result)
 def getChat(self, cid):
     dao = ChatDAO()
     result = dao.getChat(cid)
     if not result:
         return jsonify(Error="Chat does not exist."), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToDict(r))
         return jsonify(Chats=mapped_result)
 def getAllUsersInChat(self, cid):
     dao = ChatDAO()
     result = dao.getAllUsersInChat(cid)
     if not result:
         return jsonify(
             Error="No chat with that ID or no users in that chat"), 404
     else:
         mapped_result = []
         for r in result:
             mapped_result.append(self.mapToUsersInChatDict(r))
         return jsonify(UsersInChat=mapped_result)
 def createchat(self, owner, chatname):
     cid = ChatDAO().addNewChat(chatname, owner)
     r = self.addusertochat(cid, owner)
     return r
 def addusertochat(self, cid, uid):
     r = ChatDAO().addUsertoChat(cid, uid)
     return jsonify(Result=r), 200
Exemple #13
0
from flask import jsonify, session
from dao.ChatDAO import ChatDAO
from handler import DictBuilder as Dict

dao = ChatDAO()

###################### Main HANDLER ############################


def getAllChats():
    chat_lists = dao.getAllChats()
    if not chat_lists:
        return jsonify(Error="No Chats Found")
    result_list = []

    for row in chat_lists:
        result = Dict.chat_dict(row)
        result_list.append(result)
    return jsonify(Chats=result_list)


def getChatByID(chat_id):
    chat = dao.getChatByID(chat_id)
    if not chat:
        return jsonify(Error=" Chat not found"), 404
    print(chat)
    return jsonify(Chat=chat)


def getChatByUserID(user_id):
    rows = dao.getChatByUserID(user_id)