From fdba5d7ea730110fefd940b71b8ab15f41a297bb Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 7 Jul 2021 15:55:46 -0700 Subject: [PATCH] setup a server message for relaying info --- wowstash/blueprints/wallet/routes.py | 5 ++- wowstash/cli.py | 15 ++++++++- wowstash/models.py | 10 ++++++ wowstash/templates/meta/server_message.html | 35 +++++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 wowstash/templates/meta/server_message.html 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' %} + +
+
+
+
+
+

Privacy Policy

+

Here is the information I will collect from you:

+
    +
  • Web server access logs (Source IP address, browser user-agent, page requests, etc)
  • +
  • Email address and salted/hashed password (registration)
  • +
  • Application events and metrics (function execution and the user who triggered)
  • +
+

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.

+
+
+
+
+
+ + {% include 'footer.html' %} + + {% include 'scripts.html' %} + + + +