def getNameByChatId(self, id): dao = ChatDAO() result = dao.getNameByChatId(id) mappedResult = [] for r in result: mappedResult.append(self.mapToAdminDictionary(r)) return jsonify(Admin=mappedResult)
def getAllChatsMember(self, id): dao = ChatDAO() result = dao.getAllChatsMember(id) mappedResult = [] for r in result: mappedResult.append(self.mapToDictionaryNames(r)) return mappedResult
def getChatById(self, id): dao = ChatDAO() result = dao.getChatById(id) if result == None: return jsonify(Error="CHAT NOT FOUND"), 404 else: return self.mapToDictionary(result)
def getAllChats(self): dao = ChatDAO() result = dao.getAllChats() mappedResult = [] for r in result: mappedResult.append(self.mapToDictionary(r)) return jsonify(Chats=mappedResult)
def getAllChatsMemberJSON(self, id): dao = ChatDAO() result = dao.getAllChatsMember(id) mappedResult = [] for r in result: mappedResult.append(self.mapToDictionaryNames(r)) print(mappedResult) return jsonify(Chats=mappedResult)
def addContactToChat(self, chatId, contact): ChatDAO().addContactToChat(chatId, contact) return jsonify(ContactAddedToChat="User with id " + contact + " has been added to chat " + chatId)
def replyToMessage(self, message, replying): dao = ChatDAO() dao.reply(message, replying) return jsonify(Reply="Message '" + message + " has posted a reply to message: " + replying)
def likeMessage(self, userId, messageId, like): ChatDAO().likeMessage(userId, messageId, like)
def postMessage(self, chat, user, message): dao = ChatDAO() mid = dao.postMessage(chat, user, message) return mid