8
8
".read" : true ,
9
9
"$roomId" : {
10
10
// Append-only by anyone, and admins can add official rooms, and edit or remove rooms as well.
11
- ".write" : " (auth != null) && (!data.exists() || root.child('moderators').hasChild(auth.id ) || data.child('createdByUserId').val() === auth.id )" ,
11
+ ".write" : " (auth != null) && (!data.exists() || root.child('moderators').hasChild(auth.uid ) || data.child('createdByUserId').val() === auth.uid )" ,
12
12
".validate" : " newData.hasChildren(['name','type'])" ,
13
13
"id" : {
14
14
".validate" : " (newData.val() === $roomId)"
15
15
},
16
16
"createdByUserId" : {
17
- ".validate" : " (auth.id === newData.val())"
17
+ ".validate" : " (auth.uid === newData.val())"
18
18
},
19
19
"numUsers" : {
20
20
".validate" : " (newData.isNumber())"
21
21
},
22
22
"type" : {
23
- ".validate" : " ('public' === newData.val()) || 'private' === newData.val() || ('official' === newData.val() && (root.child('moderators').hasChild(auth.id )))"
23
+ ".validate" : " ('public' === newData.val()) || 'private' === newData.val() || ('official' === newData.val() && (root.child('moderators').hasChild(auth.uid )))"
24
24
},
25
25
// A list of users that may read messages from this room.
26
26
"authorizedUsers" : {
27
- ".write" : " (auth != null) && (!data.exists() || root.child('moderators').hasChild(auth.id ) || data.hasChild(auth.id ))"
27
+ ".write" : " (auth != null) && (!data.exists() || root.child('moderators').hasChild(auth.uid ) || data.hasChild(auth.uid ))"
28
28
}
29
29
}
30
30
},
31
31
"room-messages" : {
32
32
"$roomId" : {
33
33
// A list of messages by room, viewable by anyone for public rooms, or authorized users for private rooms.
34
- ".read" : " (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.id ))" ,
34
+ ".read" : " (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.uid ))" ,
35
35
"$msgId" : {
36
36
// Allow anyone to append to this list and allow admins to edit or remove.
37
- ".write" : " (auth != null) && (data.val() === null || root.child('moderators').hasChild(auth.id )) && (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.id )) && (!root.child('suspensions').hasChild(auth.id ) || root.child('suspensions').child(auth.id ).val() < now)" ,
37
+ ".write" : " (auth != null) && (data.val() === null || root.child('moderators').hasChild(auth.uid )) && (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.uid )) && (!root.child('suspensions').hasChild(auth.uid ) || root.child('suspensions').child(auth.uid ).val() < now)" ,
38
38
".validate" : " (newData.hasChildren(['userId','name','message','timestamp']))"
39
39
}
40
40
}
41
41
},
42
42
"room-users" : {
43
43
"$roomId" : {
44
- ".read" : " (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.id ))" ,
44
+ ".read" : " (root.child('room-metadata').child($roomId).child('type').val() != 'private' || root.child('room-metadata').child($roomId).child('authorizedUsers').hasChild(auth.uid ))" ,
45
45
"$userId" : {
46
46
// A list of users by room, viewable by anyone for public rooms, or authorized users for private rooms.
47
- ".write" : " (auth != null) && ($userId === auth.id || root.child('moderators').hasChild(auth.id ))" ,
47
+ ".write" : " (auth != null) && ($userId === auth.uid || root.child('moderators').hasChild(auth.uid ))" ,
48
48
"$sessionId" : {
49
49
".validate" : " (!newData.exists() || newData.hasChildren(['id','name']))"
50
50
}
54
54
"users" : {
55
55
// A list of users and their associated metadata, which can be updated by the single user or a moderator.
56
56
"$userId" : {
57
- ".write" : " (auth != null) && (auth.id === $userId || (root.child('moderators').hasChild(auth.id )))" ,
58
- ".read" : " (auth != null) && (auth.id === $userId || (root.child('moderators').hasChild(auth.id )))" ,
57
+ ".write" : " (auth != null) && (auth.uid === $userId || (root.child('moderators').hasChild(auth.uid )))" ,
58
+ ".read" : " (auth != null) && (auth.uid === $userId || (root.child('moderators').hasChild(auth.uid )))" ,
59
59
".validate" : " ($userId === newData.child('id').val())" ,
60
60
"invites" : {
61
61
// A list of chat invitations from other users, append-only by anyone.
62
62
"$inviteId" : {
63
63
// Allow the user who created the invitation to read the status of the invitation.
64
- ".read" : " (auth != null) && (auth.id === data.child('fromUserId').val())" ,
65
- ".write" : " (auth != null) && (!data.exists() || $userId === auth.id || data.child('fromUserId').val() === auth.id )" ,
64
+ ".read" : " (auth != null) && (auth.uid === data.child('fromUserId').val())" ,
65
+ ".write" : " (auth != null) && (!data.exists() || $userId === auth.uid || data.child('fromUserId').val() === auth.uid )" ,
66
66
".validate" : " newData.hasChildren(['fromUserId','fromUserName','roomId']) && (newData.child('id').val() === $inviteId)"
67
67
}
68
68
},
69
69
"notifications" : {
70
70
// A list of notifications, which can only be appended to by moderators.
71
71
"$notificationId" : {
72
- ".write" : " (auth != null) && (data.val() === null) && (root.child('moderators').hasChild(auth.id ))" ,
72
+ ".write" : " (auth != null) && (data.val() === null) && (root.child('moderators').hasChild(auth.uid ))" ,
73
73
".validate" : " newData.hasChildren(['fromUserId','timestamp','notificationType'])" ,
74
74
"fromUserId" : {
75
- ".validate" : " newData.val() === auth.id "
75
+ ".validate" : " newData.val() === auth.uid "
76
76
}
77
77
}
78
78
}
83
83
".read" : true ,
84
84
"$username" : {
85
85
"$sessionId" : {
86
- ".write" : " (auth != null) && (!data.exists() || !newData.exists() || data.child('id').val() === auth.id )" ,
86
+ ".write" : " (auth != null) && (!data.exists() || !newData.exists() || data.child('id').val() === auth.uid )" ,
87
87
"id" : {
88
- ".validate" : " (newData.val() === auth.id) "
88
+ ".validate" : " (newData.val() === auth.uid) "
89
89
},
90
90
"name" : {
91
91
".validate" : " (newData.isString())"
97
97
".read" : " (auth != null)"
98
98
},
99
99
"suspensions" : {
100
- ".write" : " (auth != null) && (root.child('moderators').hasChild(auth.id ))" ,
101
- ".read" : " (auth != null) && (root.child('moderators').hasChild(auth.id ))"
100
+ ".write" : " (auth != null) && (root.child('moderators').hasChild(auth.uid ))" ,
101
+ ".read" : " (auth != null) && (root.child('moderators').hasChild(auth.uid ))"
102
102
}
103
103
}
104
104
}
0 commit comments