diff options
-rw-r--r-- | server/controllers/api/remote/videos.js | 10 | ||||
-rw-r--r-- | server/tests/api/check-params/remotes.js | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js index 83d9b98bf..f8b4949cd 100644 --- a/server/controllers/api/remote/videos.js +++ b/server/controllers/api/remote/videos.js | |||
@@ -79,6 +79,16 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { | |||
79 | 79 | ||
80 | databaseUtils.startSerializableTransaction, | 80 | databaseUtils.startSerializableTransaction, |
81 | 81 | ||
82 | function assertRemoteIdAndHostUnique (t, callback) { | ||
83 | db.Video.loadByHostAndRemoteId(fromPod.host, videoToCreateData.remoteId, function (err, video) { | ||
84 | if (err) return callback(err) | ||
85 | |||
86 | if (video) return callback(new Error('RemoteId and host pair is not unique.')) | ||
87 | |||
88 | return callback(null, t) | ||
89 | }) | ||
90 | }, | ||
91 | |||
82 | function findOrCreateAuthor (t, callback) { | 92 | function findOrCreateAuthor (t, callback) { |
83 | const name = videoToCreateData.author | 93 | const name = videoToCreateData.author |
84 | const podId = fromPod.id | 94 | const podId = fromPod.id |
diff --git a/server/tests/api/check-params/remotes.js b/server/tests/api/check-params/remotes.js index c1ab9fb2b..f6a49d6e2 100644 --- a/server/tests/api/check-params/remotes.js +++ b/server/tests/api/check-params/remotes.js | |||
@@ -41,6 +41,8 @@ describe('Test remote videos API validators', function () { | |||
41 | 41 | ||
42 | describe('When adding a video', function () { | 42 | describe('When adding a video', function () { |
43 | it('Should check when adding a video') | 43 | it('Should check when adding a video') |
44 | |||
45 | it('Should not add an existing remoteId and host pair') | ||
44 | }) | 46 | }) |
45 | 47 | ||
46 | describe('When removing a video', function () { | 48 | describe('When removing a video', function () { |