Skip to content

feat(fcm): Migrate topic management to FCM v1 API - #785

Merged
lahirumaramba merged 3 commits into
devfrom
lm-fcm-topics
Sep 23, 2026
Merged

lahirumaramba merged 3 commits into
devfrom
lm-fcm-topics

Conversation

@lahirumaramba

Copy link
Copy Markdown
Member

Migrates topic management operations (SubscribeToTopic and UnsubscribeFromTopic) on the messaging client from the legacy Instance ID (IID) API to the FCM v1 REST API.

Key changes:

  • SubscribeToTopic and UnsubscribeFromTopic now target FCM v1 endpoints (/projects/{project_id}/registrations/{token}/topicSubscriptions).
  • Requests across multiple registration tokens are executed concurrently using a worker pool (up to 100 concurrent workers).
  • Existing IID methods were renamed to SubscribeToTopicLegacy and UnsubscribeFromTopicLegacy and marked as deprecated.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates topic subscription and unsubscription to the FCM v1 API, renaming the legacy methods and introducing new concurrent implementations using a worker pool, alongside updated test coverage. The review feedback highlights critical compilation errors in the new error-handling logic where fe.Response.Status is incorrectly referenced as StatusCode and fe.Response.Body is treated as an io.Reader instead of a []byte slice, which also leaves the io import unused. Additionally, the feedback suggests checking for context cancellation during batch operations and refactoring the test handlers to use simple request counters instead of storing *http.Request pointers, which may not retain their state after the handler returns.

Comment thread messaging/topic_mgt.go Outdated
Comment thread messaging/topic_mgt.go Outdated
Comment thread messaging/topic_mgt.go
Comment thread messaging/topic_mgt_test.go
Comment thread messaging/topic_mgt_test.go Outdated
Comment thread messaging/topic_mgt_test.go
Comment thread messaging/topic_mgt_test.go Outdated
lahirumaramba added a commit that referenced this pull request Sep 21, 2026
…rs in tests

Address review feedback on PR #785:
- Return ctx.Err() directly if context is cancelled during topic management requests.
- Use an integer request counter in test handlers instead of storing http.Request pointers.
- Add TestTopicManagementContextCancelled unit test.

@yvonnep165 yvonnep165 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with a few comments/questions!

Comment thread messaging/topic_mgt.go Outdated
Comment thread messaging/topic_mgt.go
Comment thread messaging/topic_mgt.go Outdated
Comment thread messaging/topic_mgt.go
Comment thread messaging/topic_mgt.go Outdated
Comment thread messaging/topic_mgt.go Outdated
lahirumaramba added a commit that referenced this pull request Sep 22, 2026
Address review feedback from yvonnep165 and jonathanedey on PR #785:
- Extract maxTopicManagementWorkers as a named constant.
- Use internal.HasSuccessStatus in topic subscription SuccessFn.
- Simplify error handling in makeTopicManagementSingleRequest by leveraging parsed FirebaseError.
- Remove redundant 409 conflict checks and unused io import.
- Add unit test for non-200 2xx success response.
@lahirumaramba lahirumaramba added the release:stage Stage a release candidate label Sep 23, 2026
Migrated SubscribeToTopic and UnsubscribeFromTopic to use the FCM v1 API with concurrent worker pool execution. Deprecated legacy IID methods and updated unit tests.
…rs in tests

Address review feedback on PR #785:
- Return ctx.Err() directly if context is cancelled during topic management requests.
- Use an integer request counter in test handlers instead of storing http.Request pointers.
- Add TestTopicManagementContextCancelled unit test.
Address review feedback from yvonnep165 and jonathanedey on PR #785:
- Extract maxTopicManagementWorkers as a named constant.
- Use internal.HasSuccessStatus in topic subscription SuccessFn.
- Simplify error handling in makeTopicManagementSingleRequest by leveraging parsed FirebaseError.
- Remove redundant 409 conflict checks and unused io import.
- Add unit test for non-200 2xx success response.
@lahirumaramba
lahirumaramba merged commit daea9f0 into dev Sep 23, 2026
13 checks passed
@lahirumaramba
lahirumaramba deleted the lm-fcm-topics branch September 23, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:stage Stage a release candidate release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants