diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/request.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/server/models/request.js b/server/models/request.js index 4d521919a..4e510e18a 100644 --- a/server/models/request.js +++ b/server/models/request.js | |||
@@ -19,14 +19,15 @@ let timer = null | |||
19 | 19 | ||
20 | const RequestSchema = mongoose.Schema({ | 20 | const RequestSchema = mongoose.Schema({ |
21 | request: mongoose.Schema.Types.Mixed, | 21 | request: mongoose.Schema.Types.Mixed, |
22 | to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'users' } ] | 22 | to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Pod' } ] |
23 | }) | 23 | }) |
24 | 24 | ||
25 | RequestSchema.statics = { | 25 | RequestSchema.statics = { |
26 | activate, | 26 | activate, |
27 | deactivate, | 27 | deactivate, |
28 | flush, | 28 | flush, |
29 | forceSend | 29 | forceSend, |
30 | list | ||
30 | } | 31 | } |
31 | 32 | ||
32 | RequestSchema.pre('save', function (next) { | 33 | RequestSchema.pre('save', function (next) { |
@@ -53,7 +54,7 @@ mongoose.model('Request', RequestSchema) | |||
53 | 54 | ||
54 | function activate () { | 55 | function activate () { |
55 | logger.info('Requests scheduler activated.') | 56 | logger.info('Requests scheduler activated.') |
56 | timer = setInterval(makeRequests.bind(this), constants.INTERVAL) | 57 | timer = setInterval(makeRequests.bind(this), constants.REQUESTS_INTERVAL) |
57 | } | 58 | } |
58 | 59 | ||
59 | function deactivate () { | 60 | function deactivate () { |
@@ -72,6 +73,10 @@ function forceSend () { | |||
72 | makeRequests.call(this) | 73 | makeRequests.call(this) |
73 | } | 74 | } |
74 | 75 | ||
76 | function list (callback) { | ||
77 | this.find({ }, callback) | ||
78 | } | ||
79 | |||
75 | // --------------------------------------------------------------------------- | 80 | // --------------------------------------------------------------------------- |
76 | 81 | ||
77 | // Make a requests to friends of a certain type | 82 | // Make a requests to friends of a certain type |