Skip to content

Unsubscribe pushes for a group another device removed - #2275

Draft
mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/removed-group-push-unsubscribe
Draft

mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/removed-group-push-unsubscribe

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

When another device removes a group (leaves it, or deletes it), this device learns about it from the user-groups config. By the time PushRegistrationWorker ran the group's unregistration, the group's user-groups entry was already gone, and that entry was the only place its auth (admin key or sub-account auth data) lived. getGroupAuth returned null, the request was never sent, and the row was deleted anyway. The push server kept sending that group's pushes until the subscription's signature expired (14 days). Leaving from this device wasn't affected: GroupLeavingWorker unsubscribes before it removes the group.

Change

  • push_registration_state gets a nullable group_auth column (DB lokiV63). PushRegistrationHandler already reads each group's info when it builds the desired registrations; it now passes the group's credentials along, and ensureRegistrations writes them to every row for that group. Writing them doesn't count as a change, so scheduling is unchanged.
  • Marking a row PENDING_UNREGISTER only rewrites state, so the credentials outlive the group's removal from the config.
  • The worker signs an unregistration with auth from the config if it can, and otherwise with the credentials on the row (ConfigFactoryProtocol.createGroupAuth). If neither can sign it, it logs why (no IDs or key material) and drops the row, because nothing will ever be able to sign it.
  • Registration (subscribe) is unchanged.
  • PushRegistrationWorker's namespace lists are now lazy, so a JVM test can load the class.

Limits

  • A group removed before this version first runs has no stored credentials, so its subscription still lapses on its own.
  • A request that fails in transit is still dropped rather than retried. That was already the case and isn't changed here.
  • Pre-signing the request when the unregistration is scheduled would have avoided storing credentials. It wasn't used because the push server only accepts an unsubscribe signature within 24 hours.

Pushes for a group this device no longer has

PushReceiver already drops them without notifying (it only logs).

Testing

  • New PushUnregistrationTest: unsubscribing a removed group with the member auth or the admin key stored on its row, unsubscribing a group still in the config with its own auth, logging and removing an unregistration nothing can sign (alongside a positive control), checking that the skip log has no key material or IDs, and checking that the handler attaches each group's credentials.
  • With the fallback disabled, exactly the two removed-group tests fail.
  • :app:testPlayDebugUnitTest: 467 passed, 0 failed.
  • The SQL was run on host sqlite3. The credentials are written once, re-writing them changes nothing, and they survive the move to PENDING_UNREGISTER.
  • On an emulator, both the upgrade from a dev build's database and a fresh install open without errors.
  • Not done: an end-to-end run with two linked devices.

A group's push unregistration was signed with auth built from its
user-groups entry. When another device removed the group, that entry was
gone before the worker ran, so the request failed, was never retried, and
its row was deleted anyway: the push server kept sending that group's
pushes until the subscription expired. Keep each group's credentials on
its push registration row (new group_auth column), fall back to them when
the config no longer has the group, and log an unregistration that still
can't be signed.

@mpretty-cyro mpretty-cyro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant