Conversation
|
Thank you for taking the time and for adding FID support, I really appreciate it! However, I don't think it can be merged in its current form.
One possible compatible approach would be a interface like I used it for App Check replay protection, for example: interface MessagingWithFidMulticast
{
public function sendMulticastToFids(...): MulticastSendReport;
}Messaging could implement both contracts while interface MessagingWithMulticast
{
public function sendMulticastToRegistrationTokens(...): MulticastSendReport;
public function sendMulticastToFids(...): MulticastSendReport;
}and While researching the changes, I noticed that FCM's deprecated token field already accepts FIDs, so we can use FIDs in the The app-instance and topic-management code still uses the legacy Instance ID API. The replacement topic-subscription API accepts registration tokens and FIDs, but does not replace all data returned by Let me know what you think! |
Adds `MessageTarget::FID`, `CloudMessage::withFid()`, the `FirebaseInstallationId(s)` value objects, `MulticastSendReport::validFids()` and `unknownFids()`, and the optional `Contract\MessagingWithMulticast` interface with `sendMulticastToRegistrationTokens()` and `sendMulticastToFids()`.
The Firebase Installation ID counterpart of `validateRegistrationTokens()`, returning the same `valid`/`unknown`/`invalid` keys. Adds `MulticastSendReport::invalidFids()` and teaches `SendReport::messageTargetWasInvalid()` about the `fid` field.
7143de5 to
e64b9e2
Compare
|
Thanks, all three points were fair. Reworked and force-pushed.
The new methods live on a I also added a On
That only leaves the I kept But your One thing I'm unsure about: |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## 8.x #1138 +/- ##
=============================================
- Coverage 87.86% 52.33% -35.53%
- Complexity 1507 1544 +37
=============================================
Files 157 159 +2
Lines 4234 4305 +71
=============================================
- Hits 3720 2253 -1467
- Misses 514 2052 +1538 |
jeromegamez
left a comment
There was a problem hiding this comment.
Thank you for the updates, I added some comments and change requests.
When you have modified the methods in the MulticastSendReport, could you please add unit tests that prove that the filtering works with the different tokens? The MulticastSendReportTest would be a good location.
Thank you!
| return $this | ||
| ->filter(static fn(SendReport $report): bool => $report->messageWasSentToUnknownToken()) | ||
| ->map(static fn(SendReport $report): string => $report->target()->value()) | ||
| ; |
There was a problem hiding this comment.
In unknownFids() you added
->filter(static fn(SendReport $report): bool => $report->target()->type() === MessageTarget::FID)but here you didn't add
->filter(static fn(SendReport $report): bool => $report->target()->type() === MessageTarget::TOKEN)| return $this | ||
| ->filter(static fn(SendReport $report): bool => $report->messageTargetWasInvalid()) | ||
| ->map(static fn(SendReport $report): string => $report->target()->value()) | ||
| ; |
There was a problem hiding this comment.
In invalidFids() you added
->filter(static fn(SendReport $report): bool => $report->target()->type() === MessageTarget::FID)but here you didn't add
->filter(static fn(SendReport $report): bool => $report->target()->type() === MessageTarget::TOKEN)| */ | ||
| private static function firebaseInstallationIdsFromEnvironment(): array | ||
| { | ||
| $value = Util::getenv('TEST_FIREBASE_INSTALLATION_IDS'); |
There was a problem hiding this comment.
You read from TEST_FIREBASE_INSTALLATION_IDS, but it's not set anywhere. Could you please add the variable to tests/.env.dist, CONTRIBUTING.md, .github/workflows/ci.yml and .github/workflows/secure-tests.yml? The secure tests don't run on external PRs, but this way I could obtain a FID for myself, run the tests locally and add it to the CI secrets.
The FCM API deprecated a message's
tokenfield in favor offid, which targets a Firebase Installation ID.tokenstays fully supported until Google decommissions it and currently also accepts FIDs, so this is additive — no action required for existing code.CloudMessage::withFid(), plusfidsupport inCloudMessage::fromArray(). Like other targets, a FID replaces a previously set one.FirebaseInstallationIdandFirebaseInstallationIdsvalue objects.MessageTarget::FID.Messaging::sendMulticast()acceptsFirebaseInstallationId(s). Strings and string arrays are still registration tokens.MulticastSendReport::validFids()andunknownFids().Unit tests, PHPStan, Rector and php-cs-fixer pass. Integration tests need a
TEST_FIREBASE_INSTALLATION_IDSenv var and weren't run locally.