-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchessParkConfig.json
45 lines (43 loc) · 1.15 KB
/
chessParkConfig.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
{
"interface":":4984",
"adminInterface":":4985",
"log":["REST"],
"databases":{
"chess-park":{
"server":"http://localhost:8091",
"bucket":"chess-park",
"sync":`
function(doc, oldDoc){
log("sync function enter as log")
if (doc.type == "match") {
log("processing match");
if (doc._deleted) {
// only owners can delete
requireUser(oldDoc.ownerId);
} else {
if (doc.status == "active") {
requireUser([doc.ownerId, doc.opponentId]);
channel("games-" + doc.ownerId);
channel("games-" + doc.opponentId);
} else if (doc.status == "waiting") {
channel("games-waiting");
}
}
} else if (doc.type == "userProfile") {
log("processing user profile");
// only users can update their user profile
requireUser(doc.userId);
// for now, only users can see their profiles (no friend support)
channel("userprofile-" + doc.userId);
// if a profile is present, grant them access to their own games channel
access(doc.userId, "userprofile-" + doc.userId);
access(doc.userId, "games-" + doc.userId);
access(doc.userId, "games-waiting");
} else {
channel(doc.channels);
}
}
`
}
}
}