From 49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2016 20:03:04 +0100 Subject: Pod URL -> pod host. HTTPS is required to make friends. Reason: in a network with mix http/https pods, https pods won't be able to play videos from http pod (insecure requests). --- server/controllers/api/pods.js | 16 ++++---- server/controllers/api/remote.js | 12 +++--- server/helpers/custom-validators/pods.js | 12 +++--- server/helpers/custom-validators/videos.js | 6 +-- server/helpers/requests.js | 8 ++-- server/initializers/constants.js | 3 +- server/lib/friends.js | 59 +++++++++++++----------------- server/middlewares/pods.js | 50 +++++++++++-------------- server/middlewares/secure.js | 14 +++---- server/middlewares/validators/pods.js | 4 +- server/middlewares/validators/remote.js | 4 +- server/models/pods.js | 17 ++++----- server/models/request.js | 2 +- server/models/video.js | 32 +++++++--------- 14 files changed, 110 insertions(+), 129 deletions(-) (limited to 'server') diff --git a/server/controllers/api/pods.js b/server/controllers/api/pods.js index 853e0705b..7857fcee0 100644 --- a/server/controllers/api/pods.js +++ b/server/controllers/api/pods.js @@ -20,14 +20,14 @@ const Pod = mongoose.model('Pod') router.get('/', listPods) router.post('/', validators.podsAdd, - podsMiddleware.setBodyUrlPort, + podsMiddleware.setBodyHostPort, addPods ) router.post('/makefriends', oAuth.authenticate, admin.ensureIsAdmin, validators.makeFriends, - podsMiddleware.setBodyUrlsPort, + podsMiddleware.setBodyHostsPort, makeFriends ) router.get('/quitfriends', @@ -84,17 +84,17 @@ function addPods (req, res, next) { } function listPods (req, res, next) { - Pod.list(function (err, podsUrlList) { + Pod.list(function (err, podsList) { if (err) return next(err) - res.json(getFormatedPods(podsUrlList)) + res.json(getFormatedPods(podsList)) }) } function makeFriends (req, res, next) { - const urls = req.body.urls + const hosts = req.body.hosts - friends.makeFriends(urls, function (err) { + friends.makeFriends(hosts, function (err) { if (err) { logger.error('Could not make friends.', { error: err }) return @@ -107,11 +107,11 @@ function makeFriends (req, res, next) { } function removePods (req, res, next) { - const url = req.body.signature.url + const host = req.body.signature.host waterfall([ function loadPod (callback) { - Pod.loadByUrl(url, callback) + Pod.loadByHost(host, callback) }, function removePod (pod, callback) { diff --git a/server/controllers/api/remote.js b/server/controllers/api/remote.js index 94808693d..4085deb2d 100644 --- a/server/controllers/api/remote.js +++ b/server/controllers/api/remote.js @@ -30,7 +30,7 @@ module.exports = router function remoteVideos (req, res, next) { const requests = req.body.data - const fromUrl = req.body.signature.url + const fromHost = req.body.signature.host // We need to process in the same order to keep consistency // TODO: optimization @@ -40,7 +40,7 @@ function remoteVideos (req, res, next) { if (request.type === 'add') { addRemoteVideo(videoData, callbackEach) } else if (request.type === 'remove') { - removeRemoteVideo(videoData, fromUrl, callbackEach) + removeRemoteVideo(videoData, fromHost, callbackEach) } else { logger.error('Unkown remote request type %s.', request.type) } @@ -62,16 +62,16 @@ function addRemoteVideo (videoToCreateData, callback) { video.save(callback) } -function removeRemoteVideo (videoToRemoveData, fromUrl, callback) { +function removeRemoteVideo (videoToRemoveData, fromHost, callback) { // We need the list because we have to remove some other stuffs (thumbnail etc) - Video.listByUrlAndRemoteId(fromUrl, videoToRemoveData.remoteId, function (err, videosList) { + Video.listByHostAndRemoteId(fromHost, videoToRemoveData.remoteId, function (err, videosList) { if (err) { - logger.error('Cannot list videos from url and magnets.', { error: err }) + logger.error('Cannot list videos from host and magnets.', { error: err }) return callback(err) } if (videosList.length === 0) { - logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl }) + logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podHost: fromHost }) } each(videosList, function (video, callbackEach) { diff --git a/server/helpers/custom-validators/pods.js b/server/helpers/custom-validators/pods.js index 40f8b5d0b..0154a2424 100644 --- a/server/helpers/custom-validators/pods.js +++ b/server/helpers/custom-validators/pods.js @@ -5,14 +5,14 @@ const validator = require('express-validator').validator const miscValidators = require('./misc') const podsValidators = { - isEachUniqueUrlValid + isEachUniqueHostValid } -function isEachUniqueUrlValid (urls) { - return miscValidators.isArray(urls) && - urls.length !== 0 && - urls.every(function (url) { - return validator.isURL(url) && urls.indexOf(url) === urls.lastIndexOf(url) +function isEachUniqueHostValid (hosts) { + return miscValidators.isArray(hosts) && + hosts.length !== 0 && + hosts.every(function (host) { + return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host) }) } diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 45acb7686..4a6a62326 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js @@ -15,7 +15,7 @@ const videosValidators = { isVideoDurationValid, isVideoMagnetValid, isVideoNameValid, - isVideoPodUrlValid, + isVideoPodHostValid, isVideoTagsValid, isVideoThumbnailValid, isVideoThumbnail64Valid @@ -33,7 +33,7 @@ function isEachRemoteVideosValid (requests) { isVideoDurationValid(video.duration) && isVideoMagnetValid(video.magnet) && isVideoNameValid(video.name) && - isVideoPodUrlValid(video.podUrl) && + isVideoPodHostValid(video.podHost) && isVideoTagsValid(video.tags) && isVideoThumbnail64Valid(video.thumbnailBase64) && isVideoRemoteIdValid(video.remoteId) @@ -70,7 +70,7 @@ function isVideoNameValid (value) { return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) } -function isVideoPodUrlValid (value) { +function isVideoPodHostValid (value) { // TODO: set options (TLD...) return validator.isURL(value) } diff --git a/server/helpers/requests.js b/server/helpers/requests.js index 95775c981..06109ce16 100644 --- a/server/helpers/requests.js +++ b/server/helpers/requests.js @@ -25,7 +25,7 @@ function makeRetryRequest (params, callback) { function makeSecureRequest (params, callback) { const requestParams = { - url: params.toPod.url + params.path + url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path } // Add data with POST requst ? @@ -34,9 +34,11 @@ function makeSecureRequest (params, callback) { // Add signature if it is specified in the params if (params.sign === true) { + const host = constants.CONFIG.WEBSERVER.HOST + requestParams.json.signature = { - url: constants.CONFIG.WEBSERVER.URL, - signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL) + host, + signature: peertubeCrypto.sign(host) } } diff --git a/server/initializers/constants.js b/server/initializers/constants.js index c808aff5f..d8a13d066 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js @@ -14,7 +14,7 @@ const PAGINATION_COUNT_DEFAULT = 15 // Sortable columns per schema const SEARCHABLE_COLUMNS = { - VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ] + VIDEOS: [ 'name', 'magnetUri', 'podHost', 'author', 'tags' ] } // Sortable columns per schema @@ -55,6 +55,7 @@ const CONFIG = { } } CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT +CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT // --------------------------------------------------------------------------- diff --git a/server/lib/friends.js b/server/lib/friends.js index eafffaab0..eaea040ca 100644 --- a/server/lib/friends.js +++ b/server/lib/friends.js @@ -6,7 +6,6 @@ const eachSeries = require('async/eachSeries') const fs = require('fs') const mongoose = require('mongoose') const request = require('request') -const urlUtil = require('url') const waterfall = require('async/waterfall') const constants = require('../initializers/constants') @@ -44,7 +43,7 @@ function getMyCertificate (callback) { fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.pub', 'utf8', callback) } -function makeFriends (urls, callback) { +function makeFriends (hosts, callback) { const podsScore = {} logger.info('Make friends!') @@ -54,13 +53,13 @@ function makeFriends (urls, callback) { return callback(err) } - eachSeries(urls, function (url, callbackEach) { - computeForeignPodsList(url, podsScore, callbackEach) + eachSeries(hosts, function (host, callbackEach) { + computeForeignPodsList(host, podsScore, callbackEach) }, function (err) { if (err) return callback(err) logger.debug('Pods scores computed.', { podsScore: podsScore }) - const podsList = computeWinningPods(urls, podsScore) + const podsList = computeWinningPods(hosts, podsScore) logger.debug('Pods that we keep.', { podsToKeep: podsList }) makeRequestsToWinningPods(cert, podsList, callback) @@ -149,45 +148,45 @@ module.exports = friends // --------------------------------------------------------------------------- -function computeForeignPodsList (url, podsScore, callback) { - getForeignPodsList(url, function (err, foreignPodsList) { +function computeForeignPodsList (host, podsScore, callback) { + getForeignPodsList(host, function (err, foreignPodsList) { if (err) return callback(err) if (!foreignPodsList) foreignPodsList = [] // Let's give 1 point to the pod we ask the friends list - foreignPodsList.push({ url: url }) + foreignPodsList.push({ host }) foreignPodsList.forEach(function (foreignPod) { - const foreignPodUrl = foreignPod.url + const foreignPodHost = foreignPod.host - if (podsScore[foreignPodUrl]) podsScore[foreignPodUrl]++ - else podsScore[foreignPodUrl] = 1 + if (podsScore[foreignPodHost]) podsScore[foreignPodHost]++ + else podsScore[foreignPodHost] = 1 }) callback() }) } -function computeWinningPods (urls, podsScore) { +function computeWinningPods (hosts, podsScore) { // Build the list of pods to add // Only add a pod if it exists in more than a half base pods const podsList = [] - const baseScore = urls.length / 2 - Object.keys(podsScore).forEach(function (podUrl) { + const baseScore = hosts.length / 2 + Object.keys(podsScore).forEach(function (podHost) { // If the pod is not me and with a good score we add it - if (isMe(podUrl) === false && podsScore[podUrl] > baseScore) { - podsList.push({ url: podUrl }) + if (isMe(podHost) === false && podsScore[podHost] > baseScore) { + podsList.push({ host: podHost }) } }) return podsList } -function getForeignPodsList (url, callback) { +function getForeignPodsList (host, callback) { const path = '/api/' + constants.API_VERSION + '/pods' - request.get(url + path, function (err, response, body) { + request.get(constants.REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) { if (err) return callback(err) try { @@ -207,26 +206,26 @@ function makeRequestsToWinningPods (cert, podsList, callback) { eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) { const params = { - url: pod.url + '/api/' + constants.API_VERSION + '/pods/', + url: constants.REMOTE_SCHEME.HTTP + '://' + pod.host + '/api/' + constants.API_VERSION + '/pods/', method: 'POST', json: { - url: constants.CONFIG.WEBSERVER.URL, + host: constants.CONFIG.WEBSERVER.HOST, publicKey: cert } } requests.makeRetryRequest(params, function (err, res, body) { if (err) { - logger.error('Error with adding %s pod.', pod.url, { error: err }) + logger.error('Error with adding %s pod.', pod.host, { error: err }) // Don't break the process return callbackEach() } if (res.statusCode === 200) { - const podObj = new Pod({ url: pod.url, publicKey: body.cert }) + const podObj = new Pod({ host: pod.host, publicKey: body.cert }) podObj.save(function (err, podCreated) { if (err) { - logger.error('Cannot add friend %s pod.', pod.url, { error: err }) + logger.error('Cannot add friend %s pod.', pod.host, { error: err }) return callbackEach() } @@ -236,7 +235,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) { return callbackEach() }) } else { - logger.error('Status not 200 for %s pod.', pod.url) + logger.error('Status not 200 for %s pod.', pod.host) return callbackEach() } }) @@ -268,14 +267,6 @@ function createRequest (type, endpoint, data, to) { }) } -function isMe (url) { - const parsedUrl = urlUtil.parse(url) - - const hostname = parsedUrl.hostname - const port = parseInt(parsedUrl.port) - - const myHostname = constants.CONFIG.WEBSERVER.HOSTNAME - const myPort = constants.CONFIG.WEBSERVER.PORT - - return hostname === myHostname && port === myPort +function isMe (host) { + return host === constants.CONFIG.WEBSERVER.HOST } diff --git a/server/middlewares/pods.js b/server/middlewares/pods.js index 6e0874a76..487ea1259 100644 --- a/server/middlewares/pods.js +++ b/server/middlewares/pods.js @@ -1,38 +1,36 @@ 'use strict' -const urlModule = require('url') - -const logger = require('../helpers/logger') +const constants = require('../initializers/constants') const podsMiddleware = { - setBodyUrlsPort, - setBodyUrlPort + setBodyHostsPort, + setBodyHostPort } -function setBodyUrlsPort (req, res, next) { - for (let i = 0; i < req.body.urls.length; i++) { - const urlWithPort = getUrlWithPort(req.body.urls[i]) +function setBodyHostsPort (req, res, next) { + for (let i = 0; i < req.body.hosts.length; i++) { + const hostWithPort = getHostWithPort(req.body.hosts[i]) // Problem with the url parsing? - if (urlWithPort === null) { + if (hostWithPort === null) { return res.sendStatus(500) } - req.body.urls[i] = urlWithPort + req.body.hosts[i] = hostWithPort } return next() } -function setBodyUrlPort (req, res, next) { - const urlWithPort = getUrlWithPort(req.body.url) +function setBodyHostPort (req, res, next) { + const hostWithPort = getHostWithPort(req.body.host) // Problem with the url parsing? - if (urlWithPort === null) { + if (hostWithPort === null) { return res.sendStatus(500) } - req.body.url = urlWithPort + req.body.host = hostWithPort return next() } @@ -43,20 +41,16 @@ module.exports = podsMiddleware // --------------------------------------------------------------------------- -function getUrlWithPort (url) { - const urlObj = urlModule.parse(url) - - // Add the port if it is not specified - if (urlObj.port === null) { - if (urlObj.protocol === 'http:') { - return url + ':80' - } else if (urlObj.protocol === 'https:') { - return url + ':443' - } else { - logger.error('Unknown url protocol: ' + urlObj.protocol) - return null - } +function getHostWithPort (host) { + const splitted = host.split(':') + + console.log(splitted) + // The port was not specified + if (splitted.length === 1) { + if (constants.REMOTE_SCHEME.HTTP === 'https') return host + ':443' + + return host + ':80' } - return url + return host } diff --git a/server/middlewares/secure.js b/server/middlewares/secure.js index 58f824d14..fd5bc51d6 100644 --- a/server/middlewares/secure.js +++ b/server/middlewares/secure.js @@ -12,27 +12,27 @@ const secureMiddleware = { } function checkSignature (req, res, next) { - const url = req.body.signature.url - Pod.loadByUrl(url, function (err, pod) { + const host = req.body.signature.host + Pod.loadByHost(host, function (err, pod) { if (err) { - logger.error('Cannot get signed url in decryptBody.', { error: err }) + logger.error('Cannot get signed host in decryptBody.', { error: err }) return res.sendStatus(500) } if (pod === null) { - logger.error('Unknown pod %s.', url) + logger.error('Unknown pod %s.', host) return res.sendStatus(403) } - logger.debug('Decrypting body from %s.', url) + logger.debug('Decrypting body from %s.', host) - const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, url, req.body.signature.signature) + const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, host, req.body.signature.signature) if (signatureOk === true) { return next() } - logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.url) + logger.error('Signature is not okay in decryptBody for %s.', req.body.signature.host) return res.sendStatus(403) }) } diff --git a/server/middlewares/validators/pods.js b/server/middlewares/validators/pods.js index fd3d1e2f2..4f8bad2f9 100644 --- a/server/middlewares/validators/pods.js +++ b/server/middlewares/validators/pods.js @@ -10,7 +10,7 @@ const validatorsPod = { } function makeFriends (req, res, next) { - req.checkBody('urls', 'Should have an array of unique urls').isEachUniqueUrlValid() + req.checkBody('hosts', 'Should have an array of unique hosts').isEachUniqueHostValid() logger.debug('Checking makeFriends parameters', { parameters: req.body }) @@ -32,7 +32,7 @@ function makeFriends (req, res, next) { } function podsAdd (req, res, next) { - req.checkBody('url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) + req.checkBody('host', 'Should have an host').notEmpty().isURL() req.checkBody('publicKey', 'Should have a public key').notEmpty() // TODO: check we don't have it already diff --git a/server/middlewares/validators/remote.js b/server/middlewares/validators/remote.js index 8c29ef8ca..c6455e678 100644 --- a/server/middlewares/validators/remote.js +++ b/server/middlewares/validators/remote.js @@ -27,10 +27,10 @@ function remoteVideos (req, res, next) { } function signature (req, res, next) { - req.checkBody('signature.url', 'Should have a signature url').isURL() + req.checkBody('signature.host', 'Should have a signature host').isURL() req.checkBody('signature.signature', 'Should have a signature').notEmpty() - logger.debug('Checking signature parameters', { parameters: { signatureUrl: req.body.signature.url } }) + logger.debug('Checking signature parameters', { parameters: { signatureHost: req.body.signature.host } }) checkErrors(req, res, next) } diff --git a/server/models/pods.js b/server/models/pods.js index 6ab018c1c..49c73472a 100644 --- a/server/models/pods.js +++ b/server/models/pods.js @@ -12,7 +12,7 @@ const Video = mongoose.model('Video') // --------------------------------------------------------------------------- const PodSchema = mongoose.Schema({ - url: String, + host: String, publicKey: String, score: { type: Number, max: constants.FRIEND_SCORE.MAX }, createdDate: { @@ -21,8 +21,7 @@ const PodSchema = mongoose.Schema({ } }) -// TODO: set options (TLD...) -PodSchema.path('url').validate(validator.isURL) +PodSchema.path('host').validate(validator.isURL) PodSchema.path('publicKey').required(true) PodSchema.path('score').validate(function (value) { return !isNaN(value) }) @@ -37,14 +36,14 @@ PodSchema.statics = { listAllIds, listBadPods, load, - loadByUrl, + loadByHost, removeAll } PodSchema.pre('save', function (next) { const self = this - Pod.loadByUrl(this.url, function (err, pod) { + Pod.loadByHost(this.host, function (err, pod) { if (err) return next(err) if (pod) return next(new Error('Pod already exists.')) @@ -56,7 +55,7 @@ PodSchema.pre('save', function (next) { PodSchema.pre('remove', function (next) { // Remove the videos owned by this pod too - Video.listByUrl(this.url, function (err, videos) { + Video.listByHost(this.host, function (err, videos) { if (err) return next(err) each(videos, function (video, callbackEach) { @@ -72,7 +71,7 @@ const Pod = mongoose.model('Pod', PodSchema) function toFormatedJSON () { const json = { id: this._id, - url: this.url, + host: this.host, score: this.score, createdDate: this.createdDate } @@ -111,8 +110,8 @@ function load (id, callback) { return this.findById(id, callback) } -function loadByUrl (url, callback) { - return this.findOne({ url: url }, callback) +function loadByHost (host, callback) { + return this.findOne({ host }, callback) } function removeAll (callback) { diff --git a/server/models/request.js b/server/models/request.js index f5eec2134..59bf440fe 100644 --- a/server/models/request.js +++ b/server/models/request.js @@ -121,7 +121,7 @@ function makeRequest (toPod, requestEndpoint, requestsToMake, callback) { if (err || (res.statusCode !== 200 && res.statusCode !== 201 && res.statusCode !== 204)) { logger.error( 'Error sending secure request to %s pod.', - toPod.url, + toPod.host, { error: err || new Error('Status code not 20x : ' + res.statusCode) } diff --git a/server/models/video.js b/server/models/video.js index 0da2cb8ab..6d3fa3fb8 100644 --- a/server/models/video.js +++ b/server/models/video.js @@ -28,10 +28,9 @@ const VideoSchema = mongoose.Schema({ magnet: { infoHash: String }, - podUrl: String, + podHost: String, author: String, duration: Number, - thumbnail: String, tags: [ String ], createdDate: { type: Date, @@ -41,14 +40,9 @@ const VideoSchema = mongoose.Schema({ VideoSchema.path('name').validate(customVideosValidators.isVideoNameValid) VideoSchema.path('description').validate(customVideosValidators.isVideoDescriptionValid) -VideoSchema.path('podUrl').validate(customVideosValidators.isVideoPodUrlValid) +VideoSchema.path('podHost').validate(customVideosValidators.isVideoPodHostValid) VideoSchema.path('author').validate(customVideosValidators.isVideoAuthorValid) VideoSchema.path('duration').validate(customVideosValidators.isVideoDurationValid) -// The tumbnail can be the path or the data in base 64 -// The pre save hook will convert the base 64 data in a file on disk and replace the thumbnail key by the filename -VideoSchema.path('thumbnail').validate(function (value) { - return customVideosValidators.isVideoThumbnailValid(value) || customVideosValidators.isVideoThumbnail64Valid(value) -}) VideoSchema.path('tags').validate(customVideosValidators.isVideoTagsValid) VideoSchema.methods = { @@ -65,8 +59,8 @@ VideoSchema.methods = { VideoSchema.statics = { getDurationFromFile, listForApi, - listByUrlAndRemoteId, - listByUrl, + listByHostAndRemoteId, + listByHost, listOwned, listOwnedByAuthor, listRemotes, @@ -107,7 +101,7 @@ VideoSchema.pre('save', function (next) { if (video.isOwned()) { const videoPath = pathUtils.join(constants.CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename()) - this.podUrl = constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT + this.podHost = constants.CONFIG.WEBSERVER.HOST tasks.push( // TODO: refractoring @@ -160,8 +154,8 @@ function generateMagnetUri () { baseUrlHttp = constants.CONFIG.WEBSERVER.URL baseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT } else { - baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + this.podUrl - baseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl + baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + this.podHost + baseUrlWs = constants.REMOTE_SCHEME.WS + this.podHost } const xs = baseUrlHttp + constants.STATIC_PATHS.TORRENTS + this.getTorrentName() @@ -215,7 +209,7 @@ function toFormatedJSON () { id: this._id, name: this.name, description: this.description, - podUrl: this.podUrl, + podHost: this.podHost, isLocal: this.isOwned(), magnetUri: this.generateMagnetUri(), author: this.author, @@ -249,7 +243,7 @@ function toRemoteJSON (callback) { thumbnailBase64: new Buffer(thumbnailData).toString('base64'), tags: self.tags, createdDate: self.createdDate, - podUrl: self.podUrl + podHost: self.podHost } return callback(null, remoteVideo) @@ -271,12 +265,12 @@ function listForApi (start, count, sort, callback) { return modelUtils.listForApiWithCount.call(this, query, start, count, sort, callback) } -function listByUrlAndRemoteId (fromUrl, remoteId, callback) { - this.find({ podUrl: fromUrl, remoteId: remoteId }, callback) +function listByHostAndRemoteId (fromHost, remoteId, callback) { + this.find({ podHost: fromHost, remoteId: remoteId }, callback) } -function listByUrl (fromUrl, callback) { - this.find({ podUrl: fromUrl }, callback) +function listByHost (fromHost, callback) { + this.find({ podHost: fromHost }, callback) } function listOwned (callback) { -- cgit v1.2.3