-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
71 lines (62 loc) · 1.99 KB
/
Copy pathfirestore.rules
File metadata and controls
71 lines (62 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function signedIn() {
return request.auth != null;
}
function isLatticeRoomMember(roomId) {
return signedIn()
&& request.auth.uid in get(/databases/$(database)/documents/latticeRooms/$(roomId)).data.memberIds;
}
// Code → roomId index used by callables; clients may read codes to resolve joins
match /latticeRoomCodes/{code} {
allow read: if signedIn();
allow write: if false;
}
match /latticeRooms/{roomId} {
allow read: if isLatticeRoomMember(roomId);
allow write: if false;
match /meta/{docId} {
allow read: if isLatticeRoomMember(roomId);
allow write: if false;
}
match /chat/{messageId} {
allow read: if isLatticeRoomMember(roomId);
allow write: if false;
}
match /events/{eventId} {
allow read: if isLatticeRoomMember(roomId);
allow write: if false;
}
// Warp-style coach presence: members may write only their own doc.
// Never stores suggestion text — only that advisor was engaged.
match /presence/{uid} {
allow read: if isLatticeRoomMember(roomId);
allow create, update: if signedIn()
&& request.auth.uid == uid
&& isLatticeRoomMember(roomId)
&& request.resource.data.keys().hasOnly([
'coachRequestedAt',
'coachUsedThisMatch',
'plyCount',
]);
allow delete: if false;
}
}
// Lattice-only TEI pool (not Warp playerStats). Functions write only.
match /latticeTei/{uid} {
allow read: if true;
allow write: if false;
}
match /latticeRatingEvents/{eventId} {
allow read: if signedIn() && (
resource.data.uid == request.auth.uid
|| (
resource.data.memberUids is list
&& request.auth.uid in resource.data.memberUids
)
);
allow write: if false;
}
}
}