-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdatabase.rules.bolt
More file actions
161 lines (126 loc) · 3.83 KB
/
Copy pathdatabase.rules.bolt
File metadata and controls
161 lines (126 loc) · 3.83 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
isAllowedUser() { auth != null && auth.token.email_verified == true && auth.token.email.endsWith('@sentry.io') }
isAdmin() { prior(root.users[auth.uid].admin) == true }
isCurrentUser(uid) { auth != null && auth.uid == uid }
isUser(uid) { prior(root.users[uid]) != null }
hasSubmissions(year) { prior(root.years[year].submissionsClosed) != true }
canVote(year) { prior(root.years[year].votingEnabled) == true }
type UserRef extends String {
validate() { isUser(this) }
}
type InitialTimestamp extends Number {
validate() { (prior(this) == null && this != null) || prior(this) == this }
}
type InitialUserRef extends String {
validate() { (prior(this) == null && isCurrentUser(this)) || prior(this) == this }
}
type User {
admin: Boolean | Null,
avatarUrl: String
displayName: String,
email: String,
providerData: Object
validate() { this.admin == prior(this.admin) || isAdmin() }
}
type ProjectMember {
ts: InitialTimestamp,
validate() { isUser(key()) }
}
type ProjectMedia {
name: String,
path: String,
ts: InitialTimestamp,
}
type Project {
creator: InitialUserRef,
name: String,
summary: String | Null,
repository: String | Null,
ts: InitialTimestamp,
isIdea: Boolean | Null,
needHelp: Boolean | Null,
needHelpComments: String | Null,
year: String,
group: GroupRef | Null,
videoUrl: String | Null,
nominatedAwardCategory1: AwardCategoryRef | Null,
nominatedAwardCategory2: AwardCategoryRef | Null,
validate() {
(prior(this.members) == null || prior(this.members[auth.uid]) != null || isAdmin()) &&
(this.nominatedAwardCategory1 == null || this.nominatedAwardCategory2 == null || this.nominatedAwardCategory1 != this.nominatedAwardCategory2)
}
}
type ProjectRef extends String {
validate() { this.parent().parent().parent().projects[this] != null }
}
type Group {
name: String,
year: String,
creator: InitialUserRef,
ts: InitialTimestamp
}
type GroupRef extends String {
validate() { this.parent().parent().parent().groups[this] != null }
}
type AwardCategoryRef extends String {
validate() { this.parent().parent().parent().awardCategories[this] != null }
}
type Award {
creator: InitialUserRef,
project: ProjectRef,
name: String,
awardCategory: AwardCategoryRef,
ts: InitialTimestamp,
}
type AwardCategory {
creator: InitialUserRef,
name: String,
ts: InitialTimestamp
}
type Year {
votingEnabled: Boolean | Null,
submissionsClosed: Boolean | Null,
}
type Vote {
creator: InitialUserRef,
project: ProjectRef,
awardCategory: AwardCategoryRef,
ts: Number
validate() { ($voteId == this.creator + ':' + this.awardCategory) && this.parent().parent().projects[this.project].members[auth.uid] == null }
}
path / {
read() { isAllowedUser() }
}
path /users/{userId} is User {
write() { isAllowedUser() && isCurrentUser(userId) }
}
path /years/{year} is Year {
path /awardCategories/{awardCategoryId} is AwardCategory {
write() { isAdmin() }
index() { ["creator"] }
}
path /awards/{awardId} is Award {
write() { isAdmin() }
index() { ["creator", "project"] }
}
path /projects/{projectId} is Project {
write() { isAllowedUser() && hasSubmissions(year) }
index() { ["creator"] }
path /media/{mediaId} is ProjectMedia {}
path /members/{memberId} is ProjectMember {}
}
path /votes/{voteId} is Vote {
write() { isAllowedUser() && canVote(year) }
index() { ["creator", "awardCategory"]}
}
path /groups {
read() { isAllowedUser() }
write() { isAdmin() }
index() { ["name"] }
}
path /groups/{groupid} is Group {
read() { isAllowedUser() }
write() { isAdmin() }
index() { ["name"] }
}
write() { isAdmin() }
}