Repository navigation
feat(fcm): migrate to FCM v1, retire the legacy server-key path - #388
Open
geekbrother wants to merge 1 commit into
Open
geekbrother wants to merge 1 commit into
geekbrother wants to merge 1 commit into
Conversation
Google decommissioned the legacy FCM HTTP API in June 2024 — a POST to fcm.googleapis.com/fcm/send answers 404 — so everything reached through it is dead: both the credential check in update_fcm and the sends in providers/fcm.rs. FCM v1 was already implemented end to end and is preferred by provider selection whenever a tenant has v1 credentials; what remained was retiring the legacy half rather than leaving it to fail silently. - POST /:id/fcm returns 410 Gone with a message pointing at /:id/fcm_v1, instead of "validating" a key against the dead API, accepting any string because only a 401 mapped to failure, storing it, and restoring a suspended tenant on it. DELETE /:id/fcm still works so stale keys can be cleared. - Provider selection no longer builds a legacy provider for a tenant that has only a server key; it reports LegacyFcmApiRetired, and push_message suspends that tenant with "migrate to FCM v1" so it stops being retried and shows up as needing action. Registering v1 credentials unsuspends it, as before. - Tenant::providers() and Config::supported_providers() only advertise FCM when v1 credentials are present — a legacy-only tenant cannot receive anything, so claiming the provider was a lie. - Removed the unreachable legacy provider, its Provider::Fcm variant, the fcm crate, and the error variants that wrapped its types. - Single-tenant deployments configure FCM_V1_CREDENTIALS; FCM_API_KEY is gone from Config and the env examples. The fcm_api_key column and its store methods are untouched: existing rows stay readable so legacy-only tenants can be identified and told to migrate. No credential can be converted automatically — a v1 service account key has to come from the tenant. Tests: the legacy tests that asserted a key is accepted are replaced by one that asserts it is refused and that no FCM provider is enabled. The enabled_providers and tenant_delete variants built on legacy registration are dropped, their v1 equivalents already cover the behaviour, and tenant_update_fcm_bad is no longer ignored — it is this new test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates FCM to the v1 API and retires the legacy server-key path, which has been dead since Google decommissioned the legacy FCM HTTP API in June 2024. Probed directly:
Everything reached through that endpoint is dead — both the credential check in
update_fcmand the sends inproviders/fcm.rs. FCM v1 was already implemented end to end and is already preferred by provider selection whenever a tenant has v1 credentials, so what remained was retiring the legacy half instead of leaving it to fail silently.What was broken
POST /:id/fcm"validated" a key with a dry-run send and mapped onlyFcmError::Unauthorizedto failure. A 404 hits the_ => Ok(())arm, so any string was accepted and stored — and a suspended tenant was restored on the strength of it.Tenant::providers()then advertised FCM for a tenant whose every send 404s.Changes
POST /:id/fcm→ 410 Gone, with a message pointing at/:id/fcm_v1.DELETE /:id/fcmstill works, so a tenant carrying a stale legacy key can clear it.LegacyFcmApiRetired, andpush_messagesuspends that tenant with "Legacy FCM credentials, migrate to FCM v1" so it stops being retried and shows up as needing action. Registering v1 credentials unsuspends it, exactly as before.Tenant::providers()/Config::supported_providers()advertise FCM only when v1 credentials are present. A legacy-only tenant cannot receive anything, so claiming the provider was a lie.providers/fcm.rs, theProvider::Fcmvariant, thefcmcrate, and the error variants wrapping its types.FCM_V1_CREDENTIALS;FCM_API_KEYis gone fromConfigand the env examples.Deliberately not done
The
fcm_api_keycolumn and its store methods are untouched, so existing rows stay readable and legacy-only tenants can be identified and told to migrate. No credential can be converted automatically — a v1 service account key has to come from the tenant. Dropping the column is a later, destructive cleanup.Tests
The legacy tests asserting a key is accepted are replaced by one asserting it is refused and that no FCM provider is enabled. The
enabled_providersandtenant_deletevariants built on legacy registration are dropped — their v1 equivalents infcm_v1.rsalready cover that behaviour.tenant_update_fcm_bad, ignored in #386 because it could not pass while the dead API was consulted, is now this test.ECHO_TEST_FCM_KEYis no longer read by any test.Verification
cargo clippy -D warningsfor--tests,--features=multitenant --tests,--features functional_tests --tests, and--all-features --all-targets: cleancargo fmt --check: cleanstores::tenant::tenant_fcm, which still exercises the legacy columnNote
Stacked on #386 (
fix/ci-toolchain-drift), which unbreaks clippy and the container build. GitHub will retarget this tomainonce #386 merges. The one conflict during rebase was #386's#[ignore]stopgap, which this supersedes.🤖 Generated with Claude Code