]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/request.js
Server: add requests stats endpoint
[github/Chocobozzz/PeerTube.git] / server / models / request.js
index 4d521919a11185fd4cb3c522bd1f99be1e6061f3..4e510e18aec84d040aeea42092f63374369e5d11 100644 (file)
@@ -19,14 +19,15 @@ let timer = null
 
 const RequestSchema = mongoose.Schema({
   request: mongoose.Schema.Types.Mixed,
-  to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'users' } ]
+  to: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Pod' } ]
 })
 
 RequestSchema.statics = {
   activate,
   deactivate,
   flush,
-  forceSend
+  forceSend,
+  list
 }
 
 RequestSchema.pre('save', function (next) {
@@ -53,7 +54,7 @@ mongoose.model('Request', RequestSchema)
 
 function activate () {
   logger.info('Requests scheduler activated.')
-  timer = setInterval(makeRequests.bind(this), constants.INTERVAL)
+  timer = setInterval(makeRequests.bind(this), constants.REQUESTS_INTERVAL)
 }
 
 function deactivate () {
@@ -72,6 +73,10 @@ function forceSend () {
   makeRequests.call(this)
 }
 
+function list (callback) {
+  this.find({ }, callback)
+}
+
 // ---------------------------------------------------------------------------
 
 // Make a requests to friends of a certain type