aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/static.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r--server/controllers/static.ts247
1 files changed, 124 insertions, 123 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 8d9003a3e..35e024dda 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -2,9 +2,9 @@ import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { join } from 'path' 3import { join } from 'path'
4import { serveIndexHTML } from '@server/lib/client-html' 4import { serveIndexHTML } from '@server/lib/client-html'
5import { getRegisteredPlugins, getRegisteredThemes } from '@server/lib/config' 5import { ServerConfigManager } from '@server/lib/server-config-manager'
6import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
7import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' 7import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model'
8import { root } from '../helpers/core-utils' 8import { root } from '../helpers/core-utils'
9import { CONFIG, isEmailEnabled } from '../initializers/config' 9import { CONFIG, isEmailEnabled } from '../initializers/config'
10import { 10import {
@@ -18,10 +18,9 @@ import {
18 WEBSERVER 18 WEBSERVER
19} from '../initializers/constants' 19} from '../initializers/constants'
20import { getThemeOrDefault } from '../lib/plugins/theme-utils' 20import { getThemeOrDefault } from '../lib/plugins/theme-utils'
21import { getEnabledResolutions } from '../lib/video-transcoding'
22import { asyncMiddleware } from '../middlewares' 21import { asyncMiddleware } from '../middlewares'
23import { cacheRoute } from '../middlewares/cache' 22import { cacheRoute } from '../middlewares/cache'
24import { UserModel } from '../models/account/user' 23import { UserModel } from '../models/user/user'
25import { VideoModel } from '../models/video/video' 24import { VideoModel } from '../models/video/video'
26import { VideoCommentModel } from '../models/video/video-comment' 25import { VideoCommentModel } from '../models/video/video-comment'
27 26
@@ -161,143 +160,145 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
161 const { totalVideos } = await VideoModel.getStats() 160 const { totalVideos } = await VideoModel.getStats()
162 const { totalLocalVideoComments } = await VideoCommentModel.getStats() 161 const { totalLocalVideoComments } = await VideoCommentModel.getStats()
163 const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() 162 const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
164 let json = {}
165 163
166 if (req.params.version && (req.params.version === '2.0')) { 164 if (!req.params.version || req.params.version !== '2.0') {
167 json = { 165 return res.fail({
168 version: '2.0', 166 status: HttpStatusCode.NOT_FOUND_404,
169 software: { 167 message: 'Nodeinfo schema version not handled'
170 name: 'peertube', 168 })
171 version: PEERTUBE_VERSION 169 }
170
171 const json = {
172 version: '2.0',
173 software: {
174 name: 'peertube',
175 version: PEERTUBE_VERSION
176 },
177 protocols: [
178 'activitypub'
179 ],
180 services: {
181 inbound: [],
182 outbound: [
183 'atom1.0',
184 'rss2.0'
185 ]
186 },
187 openRegistrations: CONFIG.SIGNUP.ENABLED,
188 usage: {
189 users: {
190 total: totalUsers,
191 activeMonth: totalMonthlyActiveUsers,
192 activeHalfyear: totalHalfYearActiveUsers
172 }, 193 },
173 protocols: [ 194 localPosts: totalVideos,
174 'activitypub' 195 localComments: totalLocalVideoComments
175 ], 196 },
176 services: { 197 metadata: {
177 inbound: [], 198 taxonomy: {
178 outbound: [ 199 postsName: 'Videos'
179 'atom1.0',
180 'rss2.0'
181 ]
182 }, 200 },
183 openRegistrations: CONFIG.SIGNUP.ENABLED, 201 nodeName: CONFIG.INSTANCE.NAME,
184 usage: { 202 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
185 users: { 203 nodeConfig: {
186 total: totalUsers, 204 search: {
187 activeMonth: totalMonthlyActiveUsers, 205 remoteUri: {
188 activeHalfyear: totalHalfYearActiveUsers 206 users: CONFIG.SEARCH.REMOTE_URI.USERS,
207 anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS
208 }
189 }, 209 },
190 localPosts: totalVideos, 210 plugin: {
191 localComments: totalLocalVideoComments 211 registered: ServerConfigManager.Instance.getRegisteredPlugins()
192 },
193 metadata: {
194 taxonomy: {
195 postsName: 'Videos'
196 }, 212 },
197 nodeName: CONFIG.INSTANCE.NAME, 213 theme: {
198 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION, 214 registered: ServerConfigManager.Instance.getRegisteredThemes(),
199 nodeConfig: { 215 default: getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
200 search: { 216 },
201 remoteUri: { 217 email: {
202 users: CONFIG.SEARCH.REMOTE_URI.USERS, 218 enabled: isEmailEnabled()
203 anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS 219 },
204 } 220 contactForm: {
205 }, 221 enabled: CONFIG.CONTACT_FORM.ENABLED
206 plugin: { 222 },
207 registered: getRegisteredPlugins() 223 transcoding: {
208 }, 224 hls: {
209 theme: { 225 enabled: CONFIG.TRANSCODING.HLS.ENABLED
210 registered: getRegisteredThemes(),
211 default: getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
212 },
213 email: {
214 enabled: isEmailEnabled()
215 }, 226 },
216 contactForm: { 227 webtorrent: {
217 enabled: CONFIG.CONTACT_FORM.ENABLED 228 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
218 }, 229 },
230 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('vod')
231 },
232 live: {
233 enabled: CONFIG.LIVE.ENABLED,
219 transcoding: { 234 transcoding: {
220 hls: { 235 enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
221 enabled: CONFIG.TRANSCODING.HLS.ENABLED 236 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('live')
222 }, 237 }
223 webtorrent: { 238 },
224 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED 239 import: {
240 videos: {
241 http: {
242 enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
225 }, 243 },
226 enabledResolutions: getEnabledResolutions('vod') 244 torrent: {
227 }, 245 enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
228 live: {
229 enabled: CONFIG.LIVE.ENABLED,
230 transcoding: {
231 enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
232 enabledResolutions: getEnabledResolutions('live')
233 }
234 },
235 import: {
236 videos: {
237 http: {
238 enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
239 },
240 torrent: {
241 enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
242 }
243 }
244 },
245 autoBlacklist: {
246 videos: {
247 ofUsers: {
248 enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
249 }
250 } 246 }
251 }, 247 }
252 avatar: { 248 },
253 file: { 249 autoBlacklist: {
254 size: { 250 videos: {
255 max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max 251 ofUsers: {
256 }, 252 enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
257 extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
258 } 253 }
259 }, 254 }
260 video: { 255 },
261 image: { 256 avatar: {
262 extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME, 257 file: {
263 size: { 258 size: {
264 max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max 259 max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
265 }
266 }, 260 },
267 file: { 261 extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
268 extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME 262 }
269 } 263 },
270 }, 264 video: {
271 videoCaption: { 265 image: {
272 file: { 266 extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
273 size: { 267 size: {
274 max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max 268 max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max
275 },
276 extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
277 }
278 },
279 user: {
280 videoQuota: CONFIG.USER.VIDEO_QUOTA,
281 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
282 },
283 trending: {
284 videos: {
285 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
286 } 269 }
287 }, 270 },
288 tracker: { 271 file: {
289 enabled: CONFIG.TRACKER.ENABLED 272 extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
273 }
274 },
275 videoCaption: {
276 file: {
277 size: {
278 max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max
279 },
280 extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
290 } 281 }
282 },
283 user: {
284 videoQuota: CONFIG.USER.VIDEO_QUOTA,
285 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
286 },
287 trending: {
288 videos: {
289 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
290 }
291 },
292 tracker: {
293 enabled: CONFIG.TRACKER.ENABLED
291 } 294 }
292 } 295 }
293 } as HttpNodeinfoDiasporaSoftwareNsSchema20 296 }
294 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') 297 } as HttpNodeinfoDiasporaSoftwareNsSchema20
295 } else {
296 json = { error: 'Nodeinfo schema version not handled' }
297 res.status(HttpStatusCode.NOT_FOUND_404)
298 }
299 298
300 return res.send(json).end() 299 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"')
300 .send(json)
301 .end()
301} 302}
302 303
303function getCup (req: express.Request, res: express.Response, next: express.NextFunction) { 304function getCup (req: express.Request, res: express.Response, next: express.NextFunction) {