mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Refactor getOrCreateAPVideo
This commit is contained in:
parent
c56faf0d94
commit
304a84d59c
19 changed files with 243 additions and 209 deletions
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
|||
import { sanitizeUrl } from '@server/helpers/core-utils'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { getOrCreateVideoAndAccountAndChannel } from '@server/lib/activitypub/videos'
|
||||
import { getOrCreateAPVideo } from '@server/lib/activitypub/videos'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
|
@ -244,7 +244,7 @@ async function searchVideoURI (url: string, res: express.Response) {
|
|||
refreshVideo: false
|
||||
}
|
||||
|
||||
const result = await getOrCreateVideoAndAccountAndChannel({ videoObject: url, syncParam })
|
||||
const result = await getOrCreateAPVideo({ videoObject: url, syncParam })
|
||||
video = result ? result.video : undefined
|
||||
} catch (err) {
|
||||
logger.info('Cannot search remote video %s.', url, { err })
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
import * as express from 'express'
|
||||
import toInt from 'validator/lib/toInt'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { LiveManager } from '@server/lib/live-manager'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MVideoAccountLight } from '@server/types/models'
|
||||
import { VideosCommonQuery } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
|
||||
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants'
|
||||
import { REMOTE_SCHEME, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { sendView } from '../../../lib/activitypub/send/send-view'
|
||||
import { fetchRemoteVideoDescription } from '../../../lib/activitypub/videos'
|
||||
import { JobQueue } from '../../../lib/job-queue'
|
||||
import { Hooks } from '../../../lib/plugins/hooks'
|
||||
import { Redis } from '../../../lib/redis'
|
||||
|
@ -245,3 +246,15 @@ async function removeVideo (_req: express.Request, res: express.Response) {
|
|||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// FIXME: Should not exist, we rely on specific API
|
||||
async function fetchRemoteVideoDescription (video: MVideoAccountLight) {
|
||||
const host = video.VideoChannel.Account.Actor.Server.host
|
||||
const path = video.getDescriptionAPIPath()
|
||||
const url = REMOTE_SCHEME.HTTP + '://' + host + path
|
||||
|
||||
const { body } = await doJSONRequest<any>(url)
|
||||
return body.description || ''
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue