From 6832df6177ad973ad0e1b4f0a49d7a6da06c6e04 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 9 Oct 2026 12:08:31 +0200 Subject: feat: notifications on Android while closed, with nothing to install The phone fetches what is new every fifteen minutes with a poll secret (POST /v1/push/poll) that reads notification lines and nothing else. When a UnifiedPush distributor is already installed, the hub also pushes at once, encrypted to the phone (RFC 8291); losing the distributor falls back to fetching. The hub now honours "disable all notifications" itself: create_notification creates nothing for that account, as it already did for a muted group, so neither switch lets anything reach a phone. The interface used to be the only reader of the account-wide switch. Push endpoints are member-supplied URLs: a send refuses non-public addresses, connects to the address it checked, and follows no redirect. Android build untested here (no SDK on this machine). Co-Authored-By: Claude Opus 5.5 --- .../versions/e7f8a9b0c1d2_push_subscriptions.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py (limited to 'packages/meshbay-hub/src/meshbay_hub/db/migrations') diff --git a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py new file mode 100644 index 0000000..4311448 --- /dev/null +++ b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/e7f8a9b0c1d2_push_subscriptions.py @@ -0,0 +1,35 @@ +"""phones told about notifications: a Web Push endpoint, or a poll secret + +Revision ID: e7f8a9b0c1d2 +Revises: d4e5f6a7b8ca +""" + +from collections.abc import Sequence + +import sqlalchemy as sa +from alembic import op + +revision: str = "e7f8a9b0c1d2" +down_revision: str | Sequence[str] | None = "d4e5f6a7b8ca" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.create_table( + "push_subscriptions", + sa.Column("id", sa.String(36), primary_key=True), + sa.Column("user_id", sa.String(36), sa.ForeignKey("users.id"), nullable=False), + sa.Column("endpoint", sa.String(1024), nullable=True), + sa.Column("p256dh", sa.String(128), nullable=True), + sa.Column("auth", sa.String(32), nullable=True), + sa.Column("poll_hash", sa.String(64), nullable=True), + sa.Column("created_at", sa.DateTime(timezone=True)), + ) + op.create_index("ix_push_subscriptions_user_endpoint", "push_subscriptions", + ["user_id", "endpoint"], unique=True) + + +def downgrade() -> None: + op.drop_index("ix_push_subscriptions_user_endpoint", table_name="push_subscriptions") + op.drop_table("push_subscriptions") -- cgit v1.2.3