def get_last_message(self, chat_id): payload = { "login": self.login, "password": self.password, "chat_id": chat_id } return handle_request("get_last_message", payload, self.session.get)
def create_chat(self, username): payload = { "login": self.login, "password": self.password, "user": username } return handle_request("create_chat", payload, self.session.post)
def get_user_chats(self): payload = { "login": self.login, "password": self.password } response = handle_request("get_user_chats", payload, self.session.get) return response
def get_public_key(self, username): payload = { "login": self.login, "password": self.password, "username": username } return handle_request("get_public_key", payload, self.session.get)
def complete_signup(self, email: str, password: str, public_key: str, token: str, login: str) -> dict: payload = { "email": email, "password": password, "public_key": public_key, "token": token, "login": login } return handle_request("complete_registration", payload, self.session.post)
def search(): key, route_details = t.longest_prefix('/search') try: route_details['params']['search_string'] = request.args.get('search') except: route_details['params']['search_string'] = None if route_details['params']['search_string']: return functions.handle_request('searchpage', route_details) else: return render_template('searchpage.html', route_details=route_details), 200
def get_all_messages(self, chat_id): payload = { "login": self.login, "password": self.password, "chat_id": chat_id } response = handle_request("get_all_messages", payload, self.session.get) if response["status"] == "OK": response["messages"] = [self.decrypt_message(message) for message in response["messages"]] return response else: return response
def hello(path): path = '/' + path route_details = None if path == '/': route_details = root route_details['url'] = path else: key, route_details = t.longest_prefix(path) if key is not None: route_details['url'] = path if route_details is not None: return functions.handle_request('proxypage', route_details) else: return errors.not_found(path)
def send_message(self, type_: int, data: bytes, chat_id: str, username: str, row=None, msg=None): encrypted_data = self.encrypt_data(data, username) if encrypted_data["status"] == "OK": payload = { "login": self.login, "password": self.password, "data": encrypted_data["data"], "signature": encrypted_data["signature"], "keys": encrypted_data["keys"], "chat_id": chat_id, "name": None, "type": type_.value } return handle_request("send_message", payload, self.session.post), row, msg else: return {"status": "error", "error": encrypted_data["error"]}, row, msg
def get_user_data(self) -> dict: payload = { "login": self.login, "password": self.password } return handle_request("get_user_data", payload, self.session.get)
def sign_in(self, login: str, password: str): payload = { "login": login, "password": password } return handle_request("get_user_data", payload, self.session.get)
def initiate_signup(self, email: str): payload = { "email": email } return handle_request("initiate_registration", payload, self.session.post)