diff --git a/wowstash/blueprints/wallet/routes.py b/wowstash/blueprints/wallet/routes.py index b63c226..2099225 100644 --- a/wowstash/blueprints/wallet/routes.py +++ b/wowstash/blueprints/wallet/routes.py @@ -15,7 +15,7 @@ from wowstash.library.jsonrpc import Wallet, daemon, to_atomic from wowstash.library.cache import cache from wowstash.forms import Send, Delete, Restore from wowstash.factory import db -from wowstash.models import User +from wowstash.models import User, ServerMessage from wowstash import config @@ -83,6 +83,9 @@ def dashboard(): spend_key = wallet.spend_key() view_key = wallet.view_key() capture_event(current_user.id, 'load_dashboard') + sm = ServerMessage.query.all() + if sm: + flash(f'Server message from admin: yo') return render_template( 'wallet/dashboard.html', transfers=all_transfers, diff --git a/wowstash/cli.py b/wowstash/cli.py index e2d35eb..8df2c59 100644 --- a/wowstash/cli.py +++ b/wowstash/cli.py @@ -3,7 +3,7 @@ from flask import Blueprint, url_for import wowstash.models from wowstash.library.docker import docker -from wowstash.models import User, PasswordReset +from wowstash.models import User, PasswordReset, ServerMessage from wowstash.factory import db, bcrypt @@ -42,3 +42,16 @@ def reset_password(user_email, duration): db.session.add(pwr) db.session.commit() click.echo(f'[+] Password reset link #{pwr.id} for {user_email} expires in {duration} hours: {url_for("auth.reset", hash=pwr.hash)}') + +@bp.cli.command('set_message') +@click.argument('msg_content') +def set_message(msg_content): + s = ServerMessage.query.all() + if s: + db.session.delete(s.first()) + db.session.commit() + _s = ServerMessage( + content=msg_content + ) + db.session.add(_s) + db.session.commit() diff --git a/wowstash/models.py b/wowstash/models.py index ec39bbc..ea1dd4d 100644 --- a/wowstash/models.py +++ b/wowstash/models.py @@ -89,3 +89,13 @@ class PasswordReset(db.Model): def __repr__(self): return self.id + +class ServerMessage(db.Model): + __tablename__ = 'server_message' + + id = db.Column(db.Integer, primary_key=True) + content = db.Column(db.Text) + date = db.Column(db.DateTime, server_default=func.now()) + + def __repr__(self): + return self.id diff --git a/wowstash/templates/meta/server_message.html b/wowstash/templates/meta/server_message.html new file mode 100644 index 0000000..41916fb --- /dev/null +++ b/wowstash/templates/meta/server_message.html @@ -0,0 +1,35 @@ + + + + {% include 'head.html' %} + +
+ + {% include 'navbar.html' %} + +Here is the information I will collect from you:
+I check logs and capture events for troubleshooting purposes only. None of this data is shared with any third parties because I'm not a fucking lame.
+