return {"status": "success"}
+@bp.get("/test")
+@auth.requires_login
+def test_subscriptions():
+ notify([g.userid], "Test Notification", "If you're seeing this, it worked!", "/", None)
+ return {"status": "success"}
+
def get_user_subscriptions(userid):
rows = db.query(
"""
for userid in userids:
subs = get_user_subscriptions(userid)
for subid, sub_settings, sub in subs:
- if not (sub_settings & setting):
+ if (setting is not None) and not (sub_settings & setting):
continue # This setting is disabled for this subscription
try:
if private_key:
<label><input type="checkbox" onclick="updateSettings()" id="song-push">Anyone uploads a new song (at most once per day)</label>
</div>
+<button class="button" onclick="fetch('/push-notifications/test')">Test Notifications</button>
+
<script>
function updateSelections() {
response = client.get(f"/push-notifications/settings?subid={subid}")
assert response.json["comments"] == True
assert response.json["songs"] == True
-
+
def test_update_settings_not_logged_in(client):
response = client.post(
"/push-notifications/settings",
lsp.push_notifications.wait_all()
pushmock.assert_called_once()
+################################################################################
+# Notification self-test
+
+@mock.patch("pywebpush.webpush")
+def test_notification_self_test(pushmock, app, client, user, subid, vapid_keys):
+ client.get("/push-notifications/test")
+ lsp.push_notifications.wait_all()
+ pushmock.assert_called_once()
+