diff options
Diffstat (limited to 'server/controllers/feeds/shared/video-feed-utils.ts')
-rw-r--r-- | server/controllers/feeds/shared/video-feed-utils.ts | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/server/controllers/feeds/shared/video-feed-utils.ts b/server/controllers/feeds/shared/video-feed-utils.ts deleted file mode 100644 index b154e04fa..000000000 --- a/server/controllers/feeds/shared/video-feed-utils.ts +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' | ||
2 | import { CONFIG } from '@server/initializers/config' | ||
3 | import { WEBSERVER } from '@server/initializers/constants' | ||
4 | import { getServerActor } from '@server/models/application/application' | ||
5 | import { getCategoryLabel } from '@server/models/video/formatter' | ||
6 | import { DisplayOnlyForFollowerOptions } from '@server/models/video/sql/video' | ||
7 | import { VideoModel } from '@server/models/video/video' | ||
8 | import { MThumbnail, MUserDefault } from '@server/types/models' | ||
9 | import { VideoInclude } from '@shared/models' | ||
10 | |||
11 | export async function getVideosForFeeds (options: { | ||
12 | sort: string | ||
13 | nsfw: boolean | ||
14 | isLocal: boolean | ||
15 | include: VideoInclude | ||
16 | |||
17 | accountId?: number | ||
18 | videoChannelId?: number | ||
19 | displayOnlyForFollower?: DisplayOnlyForFollowerOptions | ||
20 | user?: MUserDefault | ||
21 | }) { | ||
22 | const server = await getServerActor() | ||
23 | |||
24 | const { data } = await VideoModel.listForApi({ | ||
25 | start: 0, | ||
26 | count: CONFIG.FEEDS.VIDEOS.COUNT, | ||
27 | displayOnlyForFollower: { | ||
28 | actorId: server.id, | ||
29 | orLocalVideos: true | ||
30 | }, | ||
31 | hasFiles: true, | ||
32 | countVideos: false, | ||
33 | |||
34 | ...options | ||
35 | }) | ||
36 | |||
37 | return data | ||
38 | } | ||
39 | |||
40 | export function getCommonVideoFeedAttributes (video: VideoModel) { | ||
41 | const localLink = WEBSERVER.URL + video.getWatchStaticPath() | ||
42 | |||
43 | const thumbnailModels: MThumbnail[] = [] | ||
44 | if (video.hasPreview()) thumbnailModels.push(video.getPreview()) | ||
45 | thumbnailModels.push(video.getMiniature()) | ||
46 | |||
47 | return { | ||
48 | title: video.name, | ||
49 | link: localLink, | ||
50 | description: mdToOneLinePlainText(video.getTruncatedDescription()), | ||
51 | content: toSafeHtml(video.description), | ||
52 | |||
53 | date: video.publishedAt, | ||
54 | nsfw: video.nsfw, | ||
55 | |||
56 | category: video.category | ||
57 | ? [ { name: getCategoryLabel(video.category) } ] | ||
58 | : undefined, | ||
59 | |||
60 | thumbnails: thumbnailModels.map(t => ({ | ||
61 | url: WEBSERVER.URL + t.getLocalStaticPath(), | ||
62 | width: t.width, | ||
63 | height: t.height | ||
64 | })) | ||
65 | } | ||
66 | } | ||