aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-02 15:47:05 +0200
committerChocobozzz <me@florianbigard.com>2021-06-02 16:57:53 +0200
commit304a84d59c3a800b7f7aef48cf55f307534c0926 (patch)
treee099aefd76aa8ee5aacef7ddfc59d79111fe474b /server/controllers/api/videos
parentc56faf0d9453490737f283b29a203bb1ca632b95 (diff)
downloadPeerTube-304a84d59c3a800b7f7aef48cf55f307534c0926.tar.gz
PeerTube-304a84d59c3a800b7f7aef48cf55f307534c0926.tar.zst
PeerTube-304a84d59c3a800b7f7aef48cf55f307534c0926.zip
Refactor getOrCreateAPVideo
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/index.ts17
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import toInt from 'validator/lib/toInt' 2import toInt from 'validator/lib/toInt'
3import { doJSONRequest } from '@server/helpers/requests'
3import { LiveManager } from '@server/lib/live-manager' 4import { LiveManager } from '@server/lib/live-manager'
4import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
6import { MVideoAccountLight } from '@server/types/models'
5import { VideosCommonQuery } from '../../../../shared' 7import { VideosCommonQuery } from '../../../../shared'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs' 8import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 9import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
8import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' 10import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
9import { logger } from '../../../helpers/logger' 11import { logger } from '../../../helpers/logger'
10import { getFormattedObjects } from '../../../helpers/utils' 12import { getFormattedObjects } from '../../../helpers/utils'
11import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' 13import { REMOTE_SCHEME, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants'
12import { sequelizeTypescript } from '../../../initializers/database' 14import { sequelizeTypescript } from '../../../initializers/database'
13import { sendView } from '../../../lib/activitypub/send/send-view' 15import { sendView } from '../../../lib/activitypub/send/send-view'
14import { fetchRemoteVideoDescription } from '../../../lib/activitypub/videos'
15import { JobQueue } from '../../../lib/job-queue' 16import { JobQueue } from '../../../lib/job-queue'
16import { Hooks } from '../../../lib/plugins/hooks' 17import { Hooks } from '../../../lib/plugins/hooks'
17import { Redis } from '../../../lib/redis' 18import { 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
253async 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}