From 202ce4d446815b92fbde3598cf5f60ea7c60d8c6 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 5 Jan 2024 14:33:18 -0700 Subject: [PATCH] add ability to send a direct notification (bypassing filters) --- webpush.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webpush.py b/webpush.py index 7aa039b..5104749 100644 --- a/webpush.py +++ b/webpush.py @@ -2,8 +2,9 @@ # # Setup with `pip install -r requirements.txt` and then `source venv/bin/activate` # -# Usage: python webpush.py "ENDPOINT|P256DH|AUTH" PRIVATE_KEY +# Usage: python webpush.py "ENDPOINT|P256DH|AUTH" PRIVATE_KEY TITLE # ... where, yes, that second arg includes the "|" character, matching sqlite output. +# A title of "DIRECT_NOTIFICATION" will show a message, bypassing TimeSafari filters. from pywebpush import webpush, WebPushException @@ -42,8 +43,14 @@ if len(sys.argv) > 1: if len(parts) > 2: subscription_info['keys']['auth'] = parts[2] +title = "Test" +if len(sys.argv) > 3: + title = sys.argv[3] + now = datetime.datetime.now().isoformat() -data = json.dumps({"title": "test", "message": f"Message at {now}"}) +message = f"Message at {now}" + +data = json.dumps({"title": title, "message": message})