Server: assert remoteId and host pair is unique

pull/40/head
Chocobozzz 2017-01-27 12:05:19 +01:00
parent b09ce6455f
commit cddadde81f
2 changed files with 12 additions and 0 deletions

View File

@ -79,6 +79,16 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
databaseUtils.startSerializableTransaction,
function assertRemoteIdAndHostUnique (t, callback) {
db.Video.loadByHostAndRemoteId(fromPod.host, videoToCreateData.remoteId, function (err, video) {
if (err) return callback(err)
if (video) return callback(new Error('RemoteId and host pair is not unique.'))
return callback(null, t)
})
},
function findOrCreateAuthor (t, callback) {
const name = videoToCreateData.author
const podId = fromPod.id

View File

@ -41,6 +41,8 @@ describe('Test remote videos API validators', function () {
describe('When adding a video', function () {
it('Should check when adding a video')
it('Should not add an existing remoteId and host pair')
})
describe('When removing a video', function () {