-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-server.js
51 lines (50 loc) · 1.85 KB
/
common-server.js
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
//common-server.js
if (Meteor.isServer) {
Meteor.publish("roles", function () {
return Roles.find({});
});
Meteor.publish("votes", function () {
return Votes.find({}, {fields: {_id: 1, votefor: 1, voteType: 1, roomId: 1}});
});
Meteor.publish("gamestate", function () {
user = Meteor.users.findOne({'_id': this.userId})
return Gamestate.find({'_id': user.profile.roomId});
});
Meteor.publish("gamestateAll", function () {
user = Meteor.users.findOne({'_id': this.userId})
return Gamestate.find({});
});
Meteor.publish('allUsers', function() {
user = Meteor.users.findOne({'_id': this.userId})
if (user.profile.team == 'Werewolves') {
return Meteor.users.find({$and: [{'profile.roomId': user.profile.roomId}, {'profile.online': true}]}, {
fields: {
_id: 1,
username: 1,
'profile.alive': 1,
'profile.online': 1,
'profile.roomId': 1,
'profile.idle': 1,
'profile.death': 1,
'profile.team': 1,
'profile.reveal_role': 1,
'profile.death_location': 1
}
});
} else {
return Meteor.users.find({$and: [{'profile.roomId': user.profile.roomId}, {'profile.online': true}]}, {
fields: {
_id: 1,
username: 1,
'profile.alive': 1,
'profile.online': 1,
'profile.roomId': 1,
'profile.idle': 1,
'profile.death': 1,
'profile.reveal_role': 1,
'profile.death_location': 1
}
});
}
});
}