Skip to content

Pro: turn the badge on when an account gets its first ever proof - #2214

Open
mpretty-cyro wants to merge 1 commit into
devfrom
fix/pro-badge-on-first-proof
Open

mpretty-cyro wants to merge 1 commit into
devfrom
fix/pro-badge-on-first-proof

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

The Pro badge is off by default, so a new subscriber had to find the toggle in Pro settings before anyone could tell they had subscribed. Desktop has done this since 266ac2c9e ("setProBadge on when recovering pro without swarm config"); this is the same behaviour on Android, client-side only.

The guard is "has this account ever held Pro", not "does it hold Pro now"

The obvious reading — enable the badge whenever Pro becomes active — is wrong in a way that is easy to ship and annoying to diagnose: a subscriber who deliberately turns the badge off has it turned back on at every proof renewal, with no way to make the choice stick. Being visible as a subscriber is the user's call, which is why the badge is off by default in the first place.

So the condition is all three of proConfig, proAccessExpiry and the profile-feature bitset being absent, matching Desktop. proAccessExpiry is the value doing the real work: a lapsed plan has its proof cleared but keeps its expiry, so that expiry is what separates a returning subscriber from a first-time one.

A linked device is unaffected — it takes the badge from the user-profile config it merges, and that config's proof or expiry fails the guard in any case. A device that syncs a config with the badge off keeps it off.

Why the proof write moved

storeProof is extracted so a test can drive it. doWork() itself is unreachable from a JVM unit test: it calls ED25519, an external object whose class initialiser loads libsession's native library. The ordering constraint is now stated at both ends — the guard reads the access expiry, so it has to run before the response's expiry is written.

Testing

ProBadgeFirstProofTest — 5 tests, all passing, and proven to fail: replacing the guard with an unconditional setProBadge(true) fails 3 of the 5 (the renewing subscriber, the lapsed subscriber, and the account whose config already carries a profile feature). Those three are the regression.

Full unit suite: 303 tests, 0 failures (:app:testPlayDebugUnitTest) — the 298 baseline plus these 5.

Companion iOS change: session-foundation/session-ios fix/pro-badge-on-first-proof.

The badge is off by default, so a new subscriber had to find the toggle in Pro
settings before anyone could tell they had subscribed. Desktop has done this
since session-desktop 266ac2c9e; this is the same behaviour.

The condition is that config carries no proof, no access expiry and no profile
features - that this account has never held Pro - rather than that Pro is active
now. Enabling on "active" would turn the badge back on at every renewal for a
subscriber who had deliberately turned it off, and since a lapsed plan keeps its
access expiry after the proof is cleared, that expiry is what tells a returning
subscriber from a first-time one.

A linked device is unaffected: it takes the badge from the user profile config
it merges, and that config's proof or expiry fails the guard in any case.

The proof write moves to ProProofGenerationWorker.storeProof so a test can drive
it - doWork() is unreachable from a JVM unit test because ED25519 loads the
native library.
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.

2 participants