aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-08 13:49:41 +0200
committerChocobozzz <me@florianbigard.com>2021-06-08 13:49:41 +0200
commitec908b4a07de6c6f9c463ef8dd0982c82d9019d6 (patch)
tree7b9eba2ce6a73ba10d64ef57e27dbeb1bad63394 /server/controllers
parent99cb53fd5af3a13886e87c6aa224d777acee9fac (diff)
downloadPeerTube-ec908b4a07de6c6f9c463ef8dd0982c82d9019d6.tar.gz
PeerTube-ec908b4a07de6c6f9c463ef8dd0982c82d9019d6.tar.zst
PeerTube-ec908b4a07de6c6f9c463ef8dd0982c82d9019d6.zip
Fix nodeinfo endpoint
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/static.ts241
1 files changed, 121 insertions, 120 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 52e104346..35e024dda 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -161,143 +161,144 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
161 const { totalLocalVideoComments } = await VideoCommentModel.getStats() 161 const { totalLocalVideoComments } = await VideoCommentModel.getStats()
162 const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() 162 const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
163 163
164 if (req.params.version && (req.params.version === '2.0')) { 164 if (!req.params.version || req.params.version !== '2.0') {
165 const json = { 165 return res.fail({
166 version: '2.0', 166 status: HttpStatusCode.NOT_FOUND_404,
167 software: { 167 message: 'Nodeinfo schema version not handled'
168 name: 'peertube', 168 })
169 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
170 }, 193 },
171 protocols: [ 194 localPosts: totalVideos,
172 'activitypub' 195 localComments: totalLocalVideoComments
173 ], 196 },
174 services: { 197 metadata: {
175 inbound: [], 198 taxonomy: {
176 outbound: [ 199 postsName: 'Videos'
177 'atom1.0',
178 'rss2.0'
179 ]
180 }, 200 },
181 openRegistrations: CONFIG.SIGNUP.ENABLED, 201 nodeName: CONFIG.INSTANCE.NAME,
182 usage: { 202 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
183 users: { 203 nodeConfig: {
184 total: totalUsers, 204 search: {
185 activeMonth: totalMonthlyActiveUsers, 205 remoteUri: {
186 activeHalfyear: totalHalfYearActiveUsers 206 users: CONFIG.SEARCH.REMOTE_URI.USERS,
207 anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS
208 }
187 }, 209 },
188 localPosts: totalVideos, 210 plugin: {
189 localComments: totalLocalVideoComments 211 registered: ServerConfigManager.Instance.getRegisteredPlugins()
190 },
191 metadata: {
192 taxonomy: {
193 postsName: 'Videos'
194 }, 212 },
195 nodeName: CONFIG.INSTANCE.NAME, 213 theme: {
196 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION, 214 registered: ServerConfigManager.Instance.getRegisteredThemes(),
197 nodeConfig: { 215 default: getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
198 search: { 216 },
199 remoteUri: { 217 email: {
200 users: CONFIG.SEARCH.REMOTE_URI.USERS, 218 enabled: isEmailEnabled()
201 anonymous: CONFIG.SEARCH.REMOTE_URI.ANONYMOUS 219 },
202 } 220 contactForm: {
203 }, 221 enabled: CONFIG.CONTACT_FORM.ENABLED
204 plugin: { 222 },
205 registered: ServerConfigManager.Instance.getRegisteredPlugins() 223 transcoding: {
206 }, 224 hls: {
207 theme: { 225 enabled: CONFIG.TRANSCODING.HLS.ENABLED
208 registered: ServerConfigManager.Instance.getRegisteredThemes(),
209 default: getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
210 },
211 email: {
212 enabled: isEmailEnabled()
213 }, 226 },
214 contactForm: { 227 webtorrent: {
215 enabled: CONFIG.CONTACT_FORM.ENABLED 228 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
216 }, 229 },
230 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('vod')
231 },
232 live: {
233 enabled: CONFIG.LIVE.ENABLED,
217 transcoding: { 234 transcoding: {
218 hls: { 235 enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
219 enabled: CONFIG.TRANSCODING.HLS.ENABLED 236 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('live')
220 }, 237 }
221 webtorrent: { 238 },
222 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED 239 import: {
240 videos: {
241 http: {
242 enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
223 }, 243 },
224 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('vod') 244 torrent: {
225 }, 245 enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
226 live: {
227 enabled: CONFIG.LIVE.ENABLED,
228 transcoding: {
229 enabled: CONFIG.LIVE.TRANSCODING.ENABLED,
230 enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('live')
231 }
232 },
233 import: {
234 videos: {
235 http: {
236 enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
237 },
238 torrent: {
239 enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
240 }
241 }
242 },
243 autoBlacklist: {
244 videos: {
245 ofUsers: {
246 enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
247 }
248 } 246 }
249 }, 247 }
250 avatar: { 248 },
251 file: { 249 autoBlacklist: {
252 size: { 250 videos: {
253 max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max 251 ofUsers: {
254 }, 252 enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
255 extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
256 } 253 }
257 }, 254 }
258 video: { 255 },
259 image: { 256 avatar: {
260 extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME, 257 file: {
261 size: { 258 size: {
262 max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max 259 max: CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max
263 }
264 }, 260 },
265 file: { 261 extensions: CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME
266 extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME 262 }
267 } 263 },
268 }, 264 video: {
269 videoCaption: { 265 image: {
270 file: { 266 extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
271 size: { 267 size: {
272 max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max 268 max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max
273 },
274 extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
275 }
276 },
277 user: {
278 videoQuota: CONFIG.USER.VIDEO_QUOTA,
279 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
280 },
281 trending: {
282 videos: {
283 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
284 } 269 }
285 }, 270 },
286 tracker: { 271 file: {
287 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
288 } 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
289 } 294 }
290 } 295 }
291 } as HttpNodeinfoDiasporaSoftwareNsSchema20 296 }
292 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') 297 } as HttpNodeinfoDiasporaSoftwareNsSchema20
293 .send(json)
294 .end()
295 }
296 298
297 return res.fail({ 299 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"')
298 status: HttpStatusCode.NOT_FOUND_404, 300 .send(json)
299 message: 'Nodeinfo schema version not handled' 301 .end()
300 })
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) {