Ejemplo n.º 1
0
    def getAllReplies(self):
        dao = ReplyDAO()
        dao1 = MessageDAO()
        dao2 = MessageDAO()
        userDAO = UserDAO()
        chatDAO = ChatDAO()
        result = dao.getAllReplies()
        mapped_result = []
        for r in result:
            reply_info = []
            result1 = dao1.getMessageById(r[0])  # array de mensaje-reply
            result2 = dao2.getMessageById(r[1])  # array de mensaje original
            reply_info.append(result1[1]) #replyer_text
            reply_info.append(result2[1]) #original_text
            # buscar user con user id
            # result1[3] - replyer_id
            replyer = userDAO.getUserById(result1[3])

            reply_info.append(replyer[1] + ' ' +replyer[2])

            # buscar chat con chat id
            # result1[4] - chat_id
            chat_name = chatDAO.getChatById(result1[4])
            reply_info.append(chat_name[1])

            reply_info.append(result1[2]) #reply_date
            reply_info.append(result2[2]) #original_message_date

            mapped_result.append(self.mapToDict(reply_info))
        return jsonify(Replies=mapped_result)
Ejemplo n.º 2
0
 def getChatByID(self, id):
     dao = ChatDAO()
     result = dao.getChatById(id)
     if result == None:
         return jsonify(Error="CHAT NOT FOUND")
     else:
         mapped = self.mapToDict(result)
         return jsonify(Chat=mapped)
Ejemplo n.º 3
0
    def getAllMemberships(self):
        dao = MemberDAO()
        dao1 = UserDAO()
        dao2 = ChatDAO()
        result = dao.getAllMemberships()

        mapped_result = []
        for r in result:
            result2 = dao1.getUserById(r[0])
            result3 = dao2.getChatById(r[1])
            r[0] = result2[1] + " " + result2[2]
            r[1] = result3[1]
            mapped_result.append(self.mapToDict(r))
        return jsonify(Members=mapped_result)
Ejemplo n.º 4
0
 def getMembershipByUID(self, user_id):
     dao = MemberDAO()
     dao1 = UserDAO()
     dao2 = ChatDAO()
     result = dao.getMembershipByUserID(user_id)
     if result == None:
         return jsonify(Error="MEMBERSHIP NOT FOUND")
     else:
         mapped_result = []
         for r in result:
             result2 = dao1.getUserById(r[0])
             result3 = dao2.getChatById(r[1])
             r[0] = result2[1] + " " + result2[2]
             r[1] = result3[1]
             mapped_result.append(self.mapToDict(r))
         return jsonify(Members=mapped_result)
Ejemplo n.º 5
0
 def getChatsAdministratedByUser(self, user_id):
     dao = AdminDAO()
     dao1 = UserDAO()
     dao2 = ChatDAO()
     result = dao.getChatsAdministratedByUser(user_id)
     if result == None:
         return jsonify(Error="CHAT NOT FOUND")
     else:
         mapped_result = []
         for r in result:
             result2 = dao1.getUserById(r[0])
             result3 = dao2.getChatById(r[1])
             r[0] = result2[1] + " " + result2[2]
             r[1] = result3[1]
             mapped_result.append(self.mapToDict(r))
         return jsonify(Admins=mapped_result)
Ejemplo n.º 6
0
 def getAdminByChatID(self, chat_id):
     dao = AdminDAO()
     dao1 = UserDAO()
     dao2 = ChatDAO()
     result = dao.getAdminsByChatID(chat_id)
     # print(result)
     if result == None:
         return jsonify(Error="ADMIN NOT FOUND")
     else:
         mapped_result = []
         for r in result:
             result2 = dao1.getUserById(r[0])
             result3 = dao2.getChatById(r[1])
             r[0] = result2[1] + " " + result2[2]
             r[1] = result3[1]
             mapped_result.append(self.mapToDict(r))
         return jsonify(Admins=mapped_result)