X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Frequests.js;fp=server%2Fmodels%2FpoolRequests.js;h=2152ae0e92756c88b10ec697e88f757d2c1f179a;hb=e3647ae226d19ed1401d4c617d35a68de1c4657a;hp=28093a94c0c66641ef6a9634a247629d6e628052;hpb=a6e7400f6470a657059225807cc2853144088dbc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/poolRequests.js b/server/models/requests.js similarity index 61% rename from server/models/poolRequests.js rename to server/models/requests.js index 28093a94c..2152ae0e9 100644 --- a/server/models/poolRequests.js +++ b/server/models/requests.js @@ -6,16 +6,16 @@ const logger = require('../helpers/logger') // --------------------------------------------------------------------------- -const poolRequestsSchema = mongoose.Schema({ +const requestsSchema = mongoose.Schema({ type: String, id: String, // Special id to find duplicates (video created we want to remove...) request: mongoose.Schema.Types.Mixed }) -const PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema) +const RequestsDB = mongoose.model('requests', requestsSchema) // --------------------------------------------------------------------------- -const PoolRequests = { +const Requests = { create: create, findById: findById, list: list, @@ -24,25 +24,25 @@ const PoolRequests = { } function create (id, type, request, callback) { - PoolRequestsDB.create({ id: id, type: type, request: request }, callback) + RequestsDB.create({ id: id, type: type, request: request }, callback) } function findById (id, callback) { - PoolRequestsDB.findOne({ id: id }, callback) + RequestsDB.findOne({ id: id }, callback) } function list (callback) { - PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) + RequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) } function removeRequestById (id, callback) { - PoolRequestsDB.remove({ id: id }, callback) + RequestsDB.remove({ id: id }, callback) } function removeRequests (ids) { - PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) { + RequestsDB.remove({ _id: { $in: ids } }, function (err) { if (err) { - logger.error('Cannot remove requests from the pool requests database.', { error: err }) + logger.error('Cannot remove requests from the requests database.', { error: err }) return // Abort } @@ -52,4 +52,4 @@ function removeRequests (ids) { // --------------------------------------------------------------------------- -module.exports = PoolRequests +module.exports = Requests