-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
72 lines (63 loc) · 2.83 KB
/
firestore.rules
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
72
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function canUpdateList(resource, request, list){
return request.resource.data.diff(resource.data).affectedKeys()
.hasOnly(list);
}
match /timeline/{timelineId}{
allow read: if true;
allow create: if true;
allow update: if true;
allow delete: if request.auth.uid == 'twitch:792857520';
}
match /hotclip/{hotclipId}{
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if request.auth.uid == resource.data.authorId || canUpdateList(resource, request, ['viewCount','likeCount','likeUids']);
allow delete: if request.auth.uid == resource.data.authorId;
match /comment/{commentId}{
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if request.auth.uid == resource.data.authorId || canUpdateList(resource, request, ['likeCount','likeUids']);
allow delete: if request.auth.uid == resource.data.authorId;
}
}
match /metadata/{metadatas}{
allow read: if true;
allow create: if request.auth != null;
allow update: if true;
allow delete: if request.auth.uid == 'twitch:792857520';
match /{clipCount}{
allow read: if true;
allow update: if true;
}
}
match /cliplist/{cliplistId}{
function Authorization(){
return request.auth.uid == resource.data.authorId;
}
function incrementCliplistCount(before, after){
return before.authorId == after.authorId &&
before.authorName == after.authorName &&
before.color == after.color &&
before.createdAt == after.createdAt &&
before.description == after.description &&
before.isPublic == after.isPublic &&
before.title == after.title &&
(before.likeCount != after.likeCount || before.likeUids != after.likeUids || before.clipCount != after.clipCount || before.clipIds != after.clipIds || before.thumbnail_url != after.thumbnail_url)
}
allow read : if request.auth.uid in resource.data.likeUids || resource.data.isPublic > 0 || Authorization();
allow create: if request.auth != null;
allow update: if Authorization() || incrementCliplistCount(resource.data, request.resource.data);
allow delete: if Authorization();
function cliplistData() {
return get(/databases/$(database)/documents/cliplist/$(cliplistId)).data
}
match /clips/{clipId}{
allow read : if cliplistData().isPublic > 0 || request.auth != null;
allow write: if cliplistData().authorId == request.auth.uid;
}
}
}
}