File tree Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ module.exports = function (config) {
3030 router . get ( '/api/user/messages/index' , auth . tokenAuth , jsonResponse ( ( request ) => {
3131 return db [ 'users.messages' ] . findEx ( { user : request . user . _id } , { sort : { date : - 1 } } )
3232 . then ( data => {
33- var messages = [ ]
33+ const messages = [ ]
3434 data . forEach ( message => {
3535 if ( ! messages . find ( i => i . _id === message . respondent ) ) {
3636 messages . push ( { _id : message . respondent , message } )
@@ -44,7 +44,7 @@ module.exports = function (config) {
4444 } )
4545 } ) )
4646 router . post ( '/api/user/messages/mark-read' , auth . tokenAuth , jsonResponse ( ( request ) => {
47- var _id = request . body . id ; var message
47+ const _id = request . body . id ; let message
4848 console . log ( _id , request . user . _id )
4949 return db [ 'users.messages' ] . findOne ( { _id, user : request . user . _id , type : 'in' } )
5050 . then ( ( _message ) => {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const EventEmitter = require('events').EventEmitter
33const { MongoClient, ObjectId } = require ( 'mongodb' )
44const Redis = require ( 'redis' )
55const fs = require ( 'fs' )
6+ const path = require ( 'fs' )
67
78const DATABASE_VERSION = 9
89
@@ -287,7 +288,7 @@ module.exports = function (config) {
287288 }
288289
289290 exports . resetAllData = ( ) => {
290- return exports . importDB ( ` ${ __dirname } /../../db.original.json` ) . then ( ( r ) => q . when ( r ) )
291+ return exports . importDB ( path . join ( __dirname , ' /../../db.original.json' ) ) . then ( ( r ) => q . when ( r ) )
291292 }
292293 Object . assign ( config . common . storage , exports )
293294 return mongo
@@ -327,7 +328,7 @@ exports.importDB = async function importDB (path = './db.json') {
327328 } else {
328329 if ( ! db [ name ] ) {
329330 console . log ( `invalid collection in db.json: ${ name } ` )
330- return
331+ return Promise . resolve ( )
331332 }
332333 return db [ name ] . drop ( ) . then ( ( ) => Promise . all ( oldcol . data . map ( row => {
333334 delete row . meta
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ module.exports = {
4343 fetch ( name , cb ) {
4444 const defer = q . defer ( )
4545 try {
46- var check = function ( ) {
46+ const check = function ( ) {
4747 redis . rpoplpush ( queues [ name ] . pending , queues [ name ] . processing )
4848 . then ( item => {
4949 if ( ! item || item === 'nil' ) {
@@ -99,7 +99,7 @@ module.exports = {
9999 whenAllDone ( name , cb ) {
100100 const defer = q . defer ( )
101101 try {
102- var check = function ( reset ) {
102+ const check = function ( reset ) {
103103 q . all ( [
104104 redis . llen ( queues [ name ] . pending ) ,
105105 redis . llen ( queues [ name ] . processing )
Original file line number Diff line number Diff line change 1-
21module . exports = function ( config ) {
32 const storage = config . common . storage
43 config . common . dbIndexes = {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ module.exports = function (config) {
2121 intents . notify = _ . take ( intents . notify , 20 )
2222 }
2323
24- var promises = [ q . when ( ) ]
24+ const promises = [ q . when ( ) ]
2525
2626 intents . notify . forEach ( ( i ) => {
2727 if ( i . groupInterval < 0 ) {
@@ -32,9 +32,9 @@ module.exports = function (config) {
3232 }
3333 i . groupInterval *= 60 * 1000
3434 i . groupInterval = Math . floor ( i . groupInterval )
35- var date = i . groupInterval ? new Date ( Math . ceil ( new Date ( ) . getTime ( ) / i . groupInterval ) * i . groupInterval ) : new Date ( )
35+ const date = i . groupInterval ? new Date ( Math . ceil ( new Date ( ) . getTime ( ) / i . groupInterval ) * i . groupInterval ) : new Date ( )
3636
37- var message = ( '' + i . message ) . substring ( 0 , 500 )
37+ const message = ( '' + i . message ) . substring ( 0 , 500 )
3838
3939 promises . push ( db [ 'users.notifications' ] . update ( {
4040 $and : [
You can’t perform that action at this time.
0 commit comments