diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-24 15:56:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-24 15:56:23 +0200 |
commit | db9d882c2567fba197754a1f6fd1d75114d33560 (patch) | |
tree | 1a3be4f42c543cec2d60117565d1c92e3297c997 /server | |
parent | 87a0cac618c8ed4a09408273d0f5a468530e8062 (diff) | |
download | PeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.tar.gz PeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.tar.zst PeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.zip |
Add ability to set default feed items count
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/feeds.ts | 10 | ||||
-rw-r--r-- | server/initializers/config.ts | 8 | ||||
-rw-r--r-- | server/initializers/constants.ts | 7 |
3 files changed, 13 insertions, 12 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index c929a6726..9eb31ed93 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Feed } from '@peertube/feed' | ||
3 | import { extname } from 'path' | 2 | import { extname } from 'path' |
3 | import { Feed } from '@peertube/feed' | ||
4 | import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' | 4 | import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' |
5 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' | 6 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' |
7 | import { VideoInclude } from '@shared/models' | 7 | import { VideoInclude } from '@shared/models' |
8 | import { buildNSFWFilter } from '../helpers/express-utils' | 8 | import { buildNSFWFilter } from '../helpers/express-utils' |
9 | import { CONFIG } from '../initializers/config' | 9 | import { CONFIG } from '../initializers/config' |
10 | import { FEEDS, MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 10 | import { MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
11 | import { | 11 | import { |
12 | asyncMiddleware, | 12 | asyncMiddleware, |
13 | commonVideosFiltersValidator, | 13 | commonVideosFiltersValidator, |
@@ -76,7 +76,7 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res | |||
76 | 76 | ||
77 | const comments = await VideoCommentModel.listForFeed({ | 77 | const comments = await VideoCommentModel.listForFeed({ |
78 | start, | 78 | start, |
79 | count: FEEDS.COUNT, | 79 | count: CONFIG.FEEDS.COMMENTS.COUNT, |
80 | videoId: video ? video.id : undefined, | 80 | videoId: video ? video.id : undefined, |
81 | accountId: account ? account.id : undefined, | 81 | accountId: account ? account.id : undefined, |
82 | videoChannelId: videoChannel ? videoChannel.id : undefined | 82 | videoChannelId: videoChannel ? videoChannel.id : undefined |
@@ -166,7 +166,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { | |||
166 | const server = await getServerActor() | 166 | const server = await getServerActor() |
167 | const { data } = await VideoModel.listForApi({ | 167 | const { data } = await VideoModel.listForApi({ |
168 | start, | 168 | start, |
169 | count: FEEDS.COUNT, | 169 | count: CONFIG.FEEDS.VIDEOS.COUNT, |
170 | sort: req.query.sort, | 170 | sort: req.query.sort, |
171 | displayOnlyForFollower: { | 171 | displayOnlyForFollower: { |
172 | actorId: server.id, | 172 | actorId: server.id, |
@@ -202,7 +202,7 @@ async function generateVideoFeedForSubscriptions (req: express.Request, res: exp | |||
202 | 202 | ||
203 | const { data } = await VideoModel.listForApi({ | 203 | const { data } = await VideoModel.listForApi({ |
204 | start, | 204 | start, |
205 | count: FEEDS.COUNT, | 205 | count: CONFIG.FEEDS.VIDEOS.COUNT, |
206 | sort: req.query.sort, | 206 | sort: req.query.sort, |
207 | nsfw, | 207 | nsfw, |
208 | 208 | ||
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 2f59e3e3e..c76a839bc 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -247,6 +247,14 @@ const CONFIG = { | |||
247 | } | 247 | } |
248 | } | 248 | } |
249 | }, | 249 | }, |
250 | FEEDS: { | ||
251 | VIDEOS: { | ||
252 | COUNT: config.get<number>('feeds.videos.count') | ||
253 | }, | ||
254 | COMMENTS: { | ||
255 | COUNT: config.get<number>('feeds.comments.count') | ||
256 | } | ||
257 | }, | ||
250 | ADMIN: { | 258 | ADMIN: { |
251 | get EMAIL () { return config.get<string>('admin.email') } | 259 | get EMAIL () { return config.get<string>('admin.email') } |
252 | }, | 260 | }, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 231b86821..824a30bd2 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -766,12 +766,6 @@ const CUSTOM_HTML_TAG_COMMENTS = { | |||
766 | SERVER_CONFIG: '<!-- server config -->' | 766 | SERVER_CONFIG: '<!-- server config -->' |
767 | } | 767 | } |
768 | 768 | ||
769 | // --------------------------------------------------------------------------- | ||
770 | |||
771 | const FEEDS = { | ||
772 | COUNT: 20 | ||
773 | } | ||
774 | |||
775 | const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000 | 769 | const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000 |
776 | const LOG_FILENAME = 'peertube.log' | 770 | const LOG_FILENAME = 'peertube.log' |
777 | const AUDIT_LOG_FILENAME = 'peertube-audit.log' | 771 | const AUDIT_LOG_FILENAME = 'peertube-audit.log' |
@@ -939,7 +933,6 @@ export { | |||
939 | ROUTE_CACHE_LIFETIME, | 933 | ROUTE_CACHE_LIFETIME, |
940 | SORTABLE_COLUMNS, | 934 | SORTABLE_COLUMNS, |
941 | HLS_STREAMING_PLAYLIST_DIRECTORY, | 935 | HLS_STREAMING_PLAYLIST_DIRECTORY, |
942 | FEEDS, | ||
943 | JOB_TTL, | 936 | JOB_TTL, |
944 | DEFAULT_THEME_NAME, | 937 | DEFAULT_THEME_NAME, |
945 | NSFW_POLICY_TYPES, | 938 | NSFW_POLICY_TYPES, |