-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v2 backend): update FCM token directly in Firestore (#1981)
Before this PR, we would update the client's FCM token by writing to the putClientSettings HTTPS endpoint. With this PR, we remove that intermediate API layer and write directly to Firestore. We don't currently use the FCM token, so the main purposes of this PR are to... * Demonstrate how we'll perform direct Firestore access. * Demonstrate how to configure the app to use the local Firebase (Firestore) emulator. * Prepare the application for later use of the FCM token. Closes #1973
- Loading branch information
1 parent
47c3334
commit 51b7330
Showing
9 changed files
with
139 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:who_app/main.dart'; | ||
|
||
void main() { | ||
test( | ||
'Firebase Emulator usage has been disabled', | ||
() { | ||
expect( | ||
USE_FIREBASE_LOCAL_EMULATORS, | ||
false, | ||
); | ||
}, | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
rules_version = '2'; | ||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
// Currently: do not allow any direct reads or writes. | ||
// TODO: this will change as we update the client to do direct reads and writes. | ||
// Default: do not allow any direct reads or writes unless otherwise specified. | ||
match /{document=**} { | ||
allow read, write: if false; | ||
} | ||
|
||
// Allow writes to the "Clients" collection, permitting users to set their FCM | ||
// tokens. | ||
// | ||
// If we were concerned about abuse, we could add constraints around what the user | ||
// needs to be writing to be allowed to write. Fortunately since this is write-only, | ||
// and since the WHO client ID is a long random string that can't be guessed by others | ||
// (preventing others from overwriting your settings) there seems to be little risk | ||
// of abuse, and we can suffice with a simple rule. | ||
match /Client/{who_client_id} { | ||
allow write: if true; | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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