aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-19 12:36:41 +0100
committerChocobozzz <me@florianbigard.com>2018-03-19 14:20:04 +0100
commit5d00a3d7aa4309f1da5ac7d6e3ed63181eb34952 (patch)
tree924c46daaac9ef56108d8c449f934b6de344ae72 /server
parent09700934b90e2ac7b1b9ed1694d9d4d52735e2e1 (diff)
downloadPeerTube-5d00a3d7aa4309f1da5ac7d6e3ed63181eb34952.tar.gz
PeerTube-5d00a3d7aa4309f1da5ac7d6e3ed63181eb34952.tar.zst
PeerTube-5d00a3d7aa4309f1da5ac7d6e3ed63181eb34952.zip
Update the api documentation
Diffstat (limited to 'server')
-rw-r--r--server/helpers/custom-validators/videos.ts7
-rw-r--r--server/lib/activitypub/process/process.ts1
-rw-r--r--server/models/video/video.ts2
-rw-r--r--server/tests/api/videos/multiple-servers.ts9
-rw-r--r--server/tests/cli/update-host.ts5
-rw-r--r--server/tests/utils/videos/videos.ts6
6 files changed, 13 insertions, 17 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index c08ddd24e..a46d715ba 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -26,12 +26,8 @@ function isVideoLicenceValid (value: number) {
26 return value === null || VIDEO_LICENCES[value] !== undefined 26 return value === null || VIDEO_LICENCES[value] !== undefined
27} 27}
28 28
29function areVideoLanguagesValid (value: number[]) {
30 return value === null || (isArray(value) && value.every(v => isVideoLanguageValid(v)))
31}
32
33function isVideoLanguageValid (value: number) { 29function isVideoLanguageValid (value: number) {
34 return VIDEO_LANGUAGES[value] !== undefined 30 return value === null || VIDEO_LANGUAGES[value] !== undefined
35} 31}
36 32
37function isVideoDurationValid (value: string) { 33function isVideoDurationValid (value: string) {
@@ -137,7 +133,6 @@ export {
137 isVideoDescriptionValid, 133 isVideoDescriptionValid,
138 isVideoFileInfoHashValid, 134 isVideoFileInfoHashValid,
139 isVideoNameValid, 135 isVideoNameValid,
140 areVideoLanguagesValid,
141 isVideoTagsValid, 136 isVideoTagsValid,
142 isVideoAbuseReasonValid, 137 isVideoAbuseReasonValid,
143 isVideoFile, 138 isVideoFile,
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index 810c28e26..7edf3bba0 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -40,6 +40,7 @@ async function processActivities (activities: Activity[], signatureActor?: Actor
40 try { 40 try {
41 await activityProcessor(activity, inboxActor) 41 await activityProcessor(activity, inboxActor)
42 } catch (err) { 42 } catch (err) {
43 logger.warn(err.stack)
43 logger.warn('Cannot process activity %s.', activity.type, err) 44 logger.warn('Cannot process activity %s.', activity.type, err)
44 } 45 }
45 } 46 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index a4d4c42f0..78789ba2c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1010,7 +1010,7 @@ export class VideoModel extends Model<VideoModel> {
1010 let language 1010 let language
1011 if (this.language) { 1011 if (this.language) {
1012 language = { 1012 language = {
1013 id: this.language + '', 1013 identifier: this.language + '',
1014 name: VideoModel.getLanguageLabel(this.language) 1014 name: VideoModel.getLanguageLabel(this.language)
1015 } 1015 }
1016 } 1016 }
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 42a1241f7..74c6b8462 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -452,7 +452,7 @@ describe('Test multiple servers', function () {
452 const res2 = await getVideo(servers[0].url, video.id) 452 const res2 = await getVideo(servers[0].url, video.id)
453 const videoDetails = res2.body 453 const videoDetails = res2.body
454 454
455 const file = videoDetails.files.find(f => f.resolution === 360) 455 const file = videoDetails.files.find(f => f.resolution.id === 360)
456 expect(file).not.to.be.undefined 456 expect(file).not.to.be.undefined
457 457
458 const torrent = await webtorrentAdd(file.magnetUri) 458 const torrent = await webtorrentAdd(file.magnetUri)
@@ -705,10 +705,9 @@ describe('Test multiple servers', function () {
705 705
706 expect(baseVideo.name).to.equal(video.name) 706 expect(baseVideo.name).to.equal(video.name)
707 expect(baseVideo.uuid).to.equal(video.uuid) 707 expect(baseVideo.uuid).to.equal(video.uuid)
708 expect(baseVideo.category).to.equal(video.category) 708 expect(baseVideo.category.id).to.equal(video.category.id)
709 expect(baseVideo.language).to.equal(video.language) 709 expect(baseVideo.language.id).to.equal(video.language.id)
710 expect(baseVideo.licence).to.equal(video.licence) 710 expect(baseVideo.licence.id).to.equal(video.licence.id)
711 expect(baseVideo.category).to.equal(video.category)
712 expect(baseVideo.nsfw).to.equal(video.nsfw) 711 expect(baseVideo.nsfw).to.equal(video.nsfw)
713 expect(baseVideo.account.name).to.equal(video.account.name) 712 expect(baseVideo.account.name).to.equal(video.account.name)
714 expect(baseVideo.account.displayName).to.equal(video.account.displayName) 713 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index 39242c494..ad56f7b1b 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -2,6 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos'
5const expect = chai.expect 6const expect = chai.expect
6 7
7import { 8import {
@@ -59,7 +60,7 @@ describe('Test update host scripts', function () {
59 60
60 for (const video of videos) { 61 for (const video of videos) {
61 const res2 = await getVideo(server.url, video.id) 62 const res2 = await getVideo(server.url, video.id)
62 const videoDetails = res2.body 63 const videoDetails: VideoDetails = res2.body
63 64
64 expect(videoDetails.files).to.have.lengthOf(4) 65 expect(videoDetails.files).to.have.lengthOf(4)
65 66
@@ -67,7 +68,7 @@ describe('Test update host scripts', function () {
67 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') 68 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
68 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') 69 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F')
69 70
70 const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution) 71 const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id)
71 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') 72 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
72 expect(announceWS).to.not.be.undefined 73 expect(announceWS).to.not.be.undefined
73 74
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts
index 3c63bedb2..424f41ed8 100644
--- a/server/tests/utils/videos/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -442,7 +442,7 @@ async function completeVideoCheck (
442 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true 442 expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true
443 443
444 for (const attributeFile of attributes.files) { 444 for (const attributeFile of attributes.files) {
445 const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution) 445 const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution)
446 expect(file).not.to.be.undefined 446 expect(file).not.to.be.undefined
447 447
448 let extension = extname(attributes.fixture) 448 let extension = extname(attributes.fixture)
@@ -451,8 +451,8 @@ async function completeVideoCheck (
451 451
452 const magnetUri = file.magnetUri 452 const magnetUri = file.magnetUri
453 expect(file.magnetUri).to.have.lengthOf.above(2) 453 expect(file.magnetUri).to.have.lengthOf.above(2)
454 expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) 454 expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`)
455 expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`) 455 expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`)
456 expect(file.resolution.id).to.equal(attributeFile.resolution) 456 expect(file.resolution.id).to.equal(attributeFile.resolution)
457 expect(file.resolution.label).to.equal(attributeFile.resolution + 'p') 457 expect(file.resolution.label).to.equal(attributeFile.resolution + 'p')
458 458