def mark_message(self, id, mark): if not grid.is_connected(): abort(200) logging.info("marking message %d as %s" % (int(id), mark)) grid.mark_message(id, mark) return redirect("/inbox")
def send_message(self): to = request.form["to"] message = request.form["message"] error = None try: if not grid.is_connected(): raise Exception('not connected') grid.send_message(to, message) except Exception as e: error = str(e) return jsonify({"error": error})
def show_message(self, id): message = {} error = None try: if not grid.is_connected(): raise Exception('not connected') message = grid.inbox_message(id) if message['data']: message['data'] = base64.b64decode(message['data']).decode("utf-8") except Exception as e: logging.exception('error while reading pwnmail message %d' % int(id)) error = str(e) return render_template('message.html', name=pwnagotchi.name(), error=error, message=message)
def inbox(self): page = request.args.get("p", default=1, type=int) inbox = {"pages": 1, "records": 0, "messages": []} error = None try: if not grid.is_connected(): raise Exception('not connected') inbox = grid.inbox(page, with_pager=True) except Exception as e: logging.exception('error while reading pwnmail inbox') error = str(e) return render_template('inbox.html', name=pwnagotchi.name(), page=page, error=error, inbox=inbox)