def dashboard(): myChats = ChatHandler().getAllChatsMember(str(id)) chats = ChatHandler().getAllChatsNames(str(id)) print(myChats) print(chats) if not id: return login() else: print("ID: ", id) return render_template('dashboard.html', chats=chats, myChats=myChats)
def getAllChats(): print(request) if request.method == 'GET': return ChatHandler().getAllChatGroups() elif request.method == 'POST': return ChatHandler().newChat(request.json)
def likeMessage(userId, messageId, like): ChatHandler().likeMessage(userId, messageId, like) return "LIKED"
def viewMessages(chatId): return ChatHandler().getMessages(chatId)
def getChatbyName(cgid, uid): return ChatHandler().getChatMsgsByUserId(cgid, uid)
def getChatByUser(): global loggedUID return ChatHandler().getChatGroupsByUserId(loggedUID)
def getAllMessagesByChat(cgid): return ChatHandler().getAllMessagesByChat(cgid)
def postMessage(chat, user, message): mid = ChatHandler().postMessage(chat, user, message) messageID = {'mid': mid} print("MID: ", messageID) return jsonify(MID=messageID)
def joinChat(): if not id: return login() ChatHandler().addContactToChat(request.form['chats'], str(id)) return dashboard()
def createChat(name): return ChatHandler().createChat(name)
def removeChat(name): return ChatHandler().removeChat(name)
def allChats(): return ChatHandler().getAllChats()
def replyToMessageREST(message, replying): return ChatHandler().replyToMessage(message, replying)
def isMember(userid): return ChatHandler().getAllChatsMemberJSON(userid)
def getChatbyID(cgid): if request.method == 'GET': return ChatHandler().getChatByID(cgid) elif request.method == 'POST': global loggedUID return ChatHandler().joinChat(request.json, loggedUID)
def addContactToChat(chat, id): return ChatHandler().addContactToChat(chat, id)
def getChatbyUser(uid): return ChatHandler().getChatGroupsByUserId(uid)
def removeContactFromChat(chat, id): return ChatHandler().removeContactFromChat(chat, id)
def getChatsNotJoined(): global loggedUID return ChatHandler().getChatsNotJoined(loggedUID)
def getChatById(chatId): return ChatHandler().getChatById(chatId)
def getChatOwner(cgid): return ChatHandler().getChatOwner(cgid)
def getAdminChatById(chatId): return ChatHandler().getAdminByChatId(chatId)
def getChatMembers(cgid): return ChatHandler().getChatMembers(cgid)
def chats(): if request.args: return ChatHandler().searchChats(request.args) else: handler = ChatHandler() return handler.getAllChats()