Cooler features and many many fixes later
This commit is contained in:
@@ -22,5 +22,27 @@ service cloud.firestore {
|
||||
// nobody can delete messages through the client
|
||||
allow delete: if false;
|
||||
}
|
||||
|
||||
// --- global "memory counter" (GlobalCountPill) -------------------------
|
||||
// a single shared doc, meta/stats, holding totalMessagesEverPosted.
|
||||
// anyone can read it (it's shown to every visitor); writes are limited to
|
||||
// just that one field, same "only these fields can change" pattern as the
|
||||
// echoCount update rule above, so this doc can't be hijacked to store
|
||||
// arbitrary data.
|
||||
match /meta/stats {
|
||||
allow read: if true;
|
||||
|
||||
// first-ever write: only the counter field, and it must be a number
|
||||
allow create: if
|
||||
request.resource.data.keys().hasOnly(['totalMessagesEverPosted']) &&
|
||||
request.resource.data.totalMessagesEverPosted is number;
|
||||
|
||||
// every later write (increment(1)) may only touch that same field
|
||||
allow update: if
|
||||
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['totalMessagesEverPosted']);
|
||||
|
||||
// nobody can delete the counter through the client
|
||||
allow delete: if false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user