diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/index.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 47ab098ef..db23e5630 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,17 +1,18 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import toInt from 'validator/lib/toInt' | 2 | import toInt from 'validator/lib/toInt' |
3 | import { doJSONRequest } from '@server/helpers/requests' | ||
3 | import { LiveManager } from '@server/lib/live-manager' | 4 | import { LiveManager } from '@server/lib/live-manager' |
4 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { MVideoAccountLight } from '@server/types/models' | ||
5 | import { VideosCommonQuery } from '../../../../shared' | 7 | import { VideosCommonQuery } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs' | 8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs' |
7 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 9 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
8 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 10 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
9 | import { logger } from '../../../helpers/logger' | 11 | import { logger } from '../../../helpers/logger' |
10 | import { getFormattedObjects } from '../../../helpers/utils' | 12 | import { getFormattedObjects } from '../../../helpers/utils' |
11 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' | 13 | import { REMOTE_SCHEME, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' |
12 | import { sequelizeTypescript } from '../../../initializers/database' | 14 | import { sequelizeTypescript } from '../../../initializers/database' |
13 | import { sendView } from '../../../lib/activitypub/send/send-view' | 15 | import { sendView } from '../../../lib/activitypub/send/send-view' |
14 | import { fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' | ||
15 | import { JobQueue } from '../../../lib/job-queue' | 16 | import { JobQueue } from '../../../lib/job-queue' |
16 | import { Hooks } from '../../../lib/plugins/hooks' | 17 | import { Hooks } from '../../../lib/plugins/hooks' |
17 | import { Redis } from '../../../lib/redis' | 18 | import { Redis } from '../../../lib/redis' |
@@ -245,3 +246,15 @@ async function removeVideo (_req: express.Request, res: express.Response) { | |||
245 | .status(HttpStatusCode.NO_CONTENT_204) | 246 | .status(HttpStatusCode.NO_CONTENT_204) |
246 | .end() | 247 | .end() |
247 | } | 248 | } |
249 | |||
250 | // --------------------------------------------------------------------------- | ||
251 | |||
252 | // FIXME: Should not exist, we rely on specific API | ||
253 | async function fetchRemoteVideoDescription (video: MVideoAccountLight) { | ||
254 | const host = video.VideoChannel.Account.Actor.Server.host | ||
255 | const path = video.getDescriptionAPIPath() | ||
256 | const url = REMOTE_SCHEME.HTTP + '://' + host + path | ||
257 | |||
258 | const { body } = await doJSONRequest<any>(url) | ||
259 | return body.description || '' | ||
260 | } | ||