mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
66
server/core/controllers/feeds/shared/video-feed-utils.ts
Normal file
66
server/core/controllers/feeds/shared/video-feed-utils.ts
Normal file
|
@ -0,0 +1,66 @@
|
|||
import { VideoIncludeType } from '@peertube/peertube-models'
|
||||
import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown.js'
|
||||
import { CONFIG } from '@server/initializers/config.js'
|
||||
import { WEBSERVER } from '@server/initializers/constants.js'
|
||||
import { getServerActor } from '@server/models/application/application.js'
|
||||
import { getCategoryLabel } from '@server/models/video/formatter/index.js'
|
||||
import { DisplayOnlyForFollowerOptions } from '@server/models/video/sql/video/index.js'
|
||||
import { VideoModel } from '@server/models/video/video.js'
|
||||
import { MThumbnail, MUserDefault } from '@server/types/models/index.js'
|
||||
|
||||
export async function getVideosForFeeds (options: {
|
||||
sort: string
|
||||
nsfw: boolean
|
||||
isLocal: boolean
|
||||
include: VideoIncludeType
|
||||
|
||||
accountId?: number
|
||||
videoChannelId?: number
|
||||
displayOnlyForFollower?: DisplayOnlyForFollowerOptions
|
||||
user?: MUserDefault
|
||||
}) {
|
||||
const server = await getServerActor()
|
||||
|
||||
const { data } = await VideoModel.listForApi({
|
||||
start: 0,
|
||||
count: CONFIG.FEEDS.VIDEOS.COUNT,
|
||||
displayOnlyForFollower: {
|
||||
actorId: server.id,
|
||||
orLocalVideos: true
|
||||
},
|
||||
hasFiles: true,
|
||||
countVideos: false,
|
||||
|
||||
...options
|
||||
})
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
export function getCommonVideoFeedAttributes (video: VideoModel) {
|
||||
const localLink = WEBSERVER.URL + video.getWatchStaticPath()
|
||||
|
||||
const thumbnailModels: MThumbnail[] = []
|
||||
if (video.hasPreview()) thumbnailModels.push(video.getPreview())
|
||||
thumbnailModels.push(video.getMiniature())
|
||||
|
||||
return {
|
||||
title: video.name,
|
||||
link: localLink,
|
||||
description: mdToOneLinePlainText(video.getTruncatedDescription()),
|
||||
content: toSafeHtml(video.description),
|
||||
|
||||
date: video.publishedAt,
|
||||
nsfw: video.nsfw,
|
||||
|
||||
category: video.category
|
||||
? [ { name: getCategoryLabel(video.category) } ]
|
||||
: undefined,
|
||||
|
||||
thumbnails: thumbnailModels.map(t => ({
|
||||
url: WEBSERVER.URL + t.getLocalStaticPath(),
|
||||
width: t.width,
|
||||
height: t.height
|
||||
}))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue