From 5d00a3d7aa4309f1da5ac7d6e3ed63181eb34952 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Mar 2018 12:36:41 +0100 Subject: Update the api documentation --- server/helpers/custom-validators/videos.ts | 7 +------ server/lib/activitypub/process/process.ts | 1 + server/models/video/video.ts | 2 +- server/tests/api/videos/multiple-servers.ts | 9 ++++----- server/tests/cli/update-host.ts | 5 +++-- server/tests/utils/videos/videos.ts | 6 +++--- 6 files changed, 13 insertions(+), 17 deletions(-) (limited to 'server') 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) { return value === null || VIDEO_LICENCES[value] !== undefined } -function areVideoLanguagesValid (value: number[]) { - return value === null || (isArray(value) && value.every(v => isVideoLanguageValid(v))) -} - function isVideoLanguageValid (value: number) { - return VIDEO_LANGUAGES[value] !== undefined + return value === null || VIDEO_LANGUAGES[value] !== undefined } function isVideoDurationValid (value: string) { @@ -137,7 +133,6 @@ export { isVideoDescriptionValid, isVideoFileInfoHashValid, isVideoNameValid, - areVideoLanguagesValid, isVideoTagsValid, isVideoAbuseReasonValid, 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 try { await activityProcessor(activity, inboxActor) } catch (err) { + logger.warn(err.stack) logger.warn('Cannot process activity %s.', activity.type, err) } } 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 { let language if (this.language) { language = { - id: this.language + '', + identifier: this.language + '', name: VideoModel.getLanguageLabel(this.language) } } 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 () { const res2 = await getVideo(servers[0].url, video.id) const videoDetails = res2.body - const file = videoDetails.files.find(f => f.resolution === 360) + const file = videoDetails.files.find(f => f.resolution.id === 360) expect(file).not.to.be.undefined const torrent = await webtorrentAdd(file.magnetUri) @@ -705,10 +705,9 @@ describe('Test multiple servers', function () { expect(baseVideo.name).to.equal(video.name) expect(baseVideo.uuid).to.equal(video.uuid) - expect(baseVideo.category).to.equal(video.category) - expect(baseVideo.language).to.equal(video.language) - expect(baseVideo.licence).to.equal(video.licence) - expect(baseVideo.category).to.equal(video.category) + expect(baseVideo.category.id).to.equal(video.category.id) + expect(baseVideo.language.id).to.equal(video.language.id) + expect(baseVideo.licence.id).to.equal(video.licence.id) expect(baseVideo.nsfw).to.equal(video.nsfw) expect(baseVideo.account.name).to.equal(video.account.name) 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 @@ import 'mocha' import * as chai from 'chai' +import { VideoDetails } from '../../../shared/models/videos' const expect = chai.expect import { @@ -59,7 +60,7 @@ describe('Test update host scripts', function () { for (const video of videos) { const res2 = await getVideo(server.url, video.id) - const videoDetails = res2.body + const videoDetails: VideoDetails = res2.body expect(videoDetails.files).to.have.lengthOf(4) @@ -67,7 +68,7 @@ describe('Test update host scripts', function () { expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') - const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution) + const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id) const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') expect(announceWS).to.not.be.undefined 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 ( expect(dateIsValid(videoDetails.channel.updatedAt)).to.be.true for (const attributeFile of attributes.files) { - const file = videoDetails.files.find(f => f.resolution === attributeFile.resolution) + const file = videoDetails.files.find(f => f.resolution.id === attributeFile.resolution) expect(file).not.to.be.undefined let extension = extname(attributes.fixture) @@ -451,8 +451,8 @@ async function completeVideoCheck ( const magnetUri = file.magnetUri expect(file.magnetUri).to.have.lengthOf.above(2) - expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`) - expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution}${extension}`) + expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`) + expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`) expect(file.resolution.id).to.equal(attributeFile.resolution) expect(file.resolution.label).to.equal(attributeFile.resolution + 'p') -- cgit v1.2.3