aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-05-24 15:56:23 +0200
committerChocobozzz <me@florianbigard.com>2022-05-24 15:56:23 +0200
commitdb9d882c2567fba197754a1f6fd1d75114d33560 (patch)
tree1a3be4f42c543cec2d60117565d1c92e3297c997
parent87a0cac618c8ed4a09408273d0f5a468530e8062 (diff)
downloadPeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.tar.gz
PeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.tar.zst
PeerTube-db9d882c2567fba197754a1f6fd1d75114d33560.zip
Add ability to set default feed items count
-rw-r--r--config/default.yaml10
-rw-r--r--config/production.yaml.example16
-rw-r--r--server/controllers/feeds.ts10
-rw-r--r--server/initializers/config.ts8
-rw-r--r--server/initializers/constants.ts7
5 files changed, 36 insertions, 15 deletions
diff --git a/config/default.yaml b/config/default.yaml
index c3e42350b..c0d17decf 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -297,6 +297,16 @@ webadmin:
297 # Set this to false if you don't want to allow config edition in the web interface by instance admins 297 # Set this to false if you don't want to allow config edition in the web interface by instance admins
298 allowed: true 298 allowed: true
299 299
300# XML, Atom or JSON feeds
301feeds:
302 videos:
303 # Default number of videos displayed in feeds
304 count: 20
305
306 comments:
307 # Default number of comments displayed in feeds
308 count: 20
309
300cache: 310cache:
301 previews: 311 previews:
302 size: 500 # Max number of previews you want to cache 312 size: 500 # Max number of previews you want to cache
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 4351a4b87..8fd8d805f 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -293,15 +293,25 @@ webadmin:
293 # Set this to false if you don't want to allow config edition in the web interface by instance admins 293 # Set this to false if you don't want to allow config edition in the web interface by instance admins
294 allowed: true 294 allowed: true
295 295
296# XML, Atom or JSON feeds
297feeds:
298 videos:
299 # Default number of videos displayed in feeds
300 count: 20
301
302 comments:
303 # Default number of comments displayed in feeds
304 count: 20
305
296############################################################################### 306###############################################################################
297# 307#
298# From this point, all the following keys can be overridden by the web interface 308# From this point, almost all following keys can be overridden by the web interface
299# (local-production.json file). If you need to change some values, prefer to 309# (local-production.json file). If you need to change some values, prefer to
300# use the web interface because the configuration will be automatically 310# use the web interface because the configuration will be automatically
301# reloaded without any need to restart PeerTube 311# reloaded without any need to restart PeerTube
302# 312#
303# /!\ If you already have a local-production.json file, the modification of the 313# /!\ If you already have a local-production.json file, modification of some of
304# following keys will have no effect /!\ 314# the following keys will have no effect /!\
305# 315#
306############################################################################### 316###############################################################################
307 317
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 @@
1import express from 'express' 1import express from 'express'
2import { Feed } from '@peertube/feed'
3import { extname } from 'path' 2import { extname } from 'path'
3import { Feed } from '@peertube/feed'
4import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' 4import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown'
5import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
6import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' 6import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
7import { VideoInclude } from '@shared/models' 7import { VideoInclude } from '@shared/models'
8import { buildNSFWFilter } from '../helpers/express-utils' 8import { buildNSFWFilter } from '../helpers/express-utils'
9import { CONFIG } from '../initializers/config' 9import { CONFIG } from '../initializers/config'
10import { FEEDS, MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 10import { MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
11import { 11import {
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
771const FEEDS = {
772 COUNT: 20
773}
774
775const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000 769const MAX_LOGS_OUTPUT_CHARACTERS = 10 * 1000 * 1000
776const LOG_FILENAME = 'peertube.log' 770const LOG_FILENAME = 'peertube.log'
777const AUDIT_LOG_FILENAME = 'peertube-audit.log' 771const 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,