-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.rules.json
81 lines (80 loc) · 2.52 KB
/
database.rules.json
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
{
"rules" : {
"channels" : {
".read" : "auth != null",
"$channelId" : {
".write" : "auth != null",
".validate" : "newData.hasChildren(['id', 'name', 'createdBy', 'details'])",
"id" : {
".validate" : "newData.val() === $channelId"
},
"name" : {
".validate" : "newData.val().length > 0"
},
"details" : {
".validate" : "newData.val().length > 0"
}
}
},
"messages" : {
"$channelId" : {
".read" : "auth != null",
".validate" : "root.child('channels/'+$channelId).exists()",
"$messageId" : {
".write" : "auth != null",
".validate" : "newData.hasChildren(['content', 'user', 'timestamp']) && !newData.hasChildren(['image']) || newData.hasChildren(['image', 'user', 'timestamp']) && !newData.hasChildren(['content'])",
"content" : {
".validate" : "newData.val().length > 0"
},
"image" : {
".validate" : "newData.val().length > 0"
},
"user" : {
".validate" : "newData.hasChildren(['id', 'name', 'avatar'])"
}
}
}
},
"privateMessages" : {
"$uid1" : {
"$uid2" : {
".read" : "auth != null && ($uid1 === auth.uid || $uid2 === auth.uid)",
"$messageId" : {
".write" : "auth != null",
".validate" : "newData.hasChildren(['content', 'user', 'timestamp']) && !newData.hasChildren(['image']) || newData.hasChildren(['image', 'user', 'timestamp']) && !newData.hasChildren(['content'])",
"content" : {
".validate" : "newData.val().length > 0"
},
"image" : {
".validate" : "newData.val().length > 0"
},
"user" : {
".validate" : "newData.hasChildren(['id', 'name', 'avatar'])"
}
}
}
}
},
"presence" : {
".read" : "auth != null",
".write" : "auth != null"
},
"typing" : {
".read" : "auth != null",
".write" : "auth != null"
},
"users" : {
".read" : "auth != null",
"$uid" : {
".write" : "auth != null && auth.uid === $uid",
".validate" : "newData.hasChildren(['name', 'avatar'])",
"name" : {
".validate" : "newData.val().length > 0"
},
"avatar" : {
".validate" : "newData.val().length > 0"
},
}
}
}
}