feat(fcm): Migrate topic management to FCM v1 API - #785
Conversation
There was a problem hiding this comment.
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.
…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
left a comment
There was a problem hiding this comment.
LGTM with a few comments/questions!
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.
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.
137a565 to
4ce2a0f
Compare
Migrates topic management operations (
SubscribeToTopicandUnsubscribeFromTopic) on the messaging client from the legacy Instance ID (IID) API to the FCM v1 REST API.Key changes:
SubscribeToTopicandUnsubscribeFromTopicnow target FCM v1 endpoints (/projects/{project_id}/registrations/{token}/topicSubscriptions).SubscribeToTopicLegacyandUnsubscribeFromTopicLegacyand marked as deprecated.