File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 84
84
modules
85
85
service-messages
86
86
meteorhacks:aggregate
87
+ admin
Original file line number Diff line number Diff line change
1
+ Package . describe ( {
2
+ name : 'admin' ,
3
+ version : '0.0.1' ,
4
+ summary : 'admin api endpoints' ,
5
+ git : '' ,
6
+ documentation : 'README.md' ,
7
+ } )
8
+
9
+ Package . onUse ( function ( api ) {
10
+ api . versionsFrom ( '1.2.1' )
11
+ api . use ( [
12
+ 'ecmascript' ,
13
+ 'tmeasday:publish-counts' ,
14
+ 'check' ,
15
+ 'mongo' ,
16
+ ] , 'server' )
17
+ api . addFiles ( 'server/publish.js' , 'server' )
18
+ } )
Original file line number Diff line number Diff line change
1
+ /* global userIsInRole, Counts, ReportItems */
2
+
3
+ function pub ( name , fn ) {
4
+ Meteor . publish ( `admin_${ name } ` , function ( ) {
5
+ if ( this . userId == null || ! userIsInRole ( this . userId , 'admin' ) ) {
6
+ this . ready ( )
7
+ return undefined
8
+ }
9
+ return fn . apply ( this , arguments )
10
+ } )
11
+ }
12
+
13
+ pub ( 'userCount' , function ( ) {
14
+ Counts . publish (
15
+ this ,
16
+ 'userCount' ,
17
+ Meteor . users . find ( { } )
18
+ )
19
+ } )
20
+
21
+ pub ( 'loggedIn' , function ( ) {
22
+ Counts . publish (
23
+ this ,
24
+ 'loggedInUsersCount' ,
25
+ Meteor . users . find ( { 'status.online' : true } )
26
+ )
27
+ } )
28
+
29
+ pub ( 'reportItems' , function ( all = false ) {
30
+ let query = { }
31
+ if ( ! all ) {
32
+ query = {
33
+ resolvedInfo : { $exists : false } ,
34
+ }
35
+ }
36
+ return ReportItems . find ( query )
37
+ } )
You can’t perform that action at this time.
0 commit comments