1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Fix nodeinfo local posts

This commit is contained in:
Chocobozzz 2025-04-15 09:36:56 +02:00
parent 8f87a6cd9f
commit d6f7b471de
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -16,36 +16,21 @@ const miscRouter = express.Router()
miscRouter.use(cors()) miscRouter.use(cors())
miscRouter.use('/nodeinfo/:version.json', miscRouter.use('/nodeinfo/:version.json', apiRateLimiter, cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO), asyncMiddleware(generateNodeinfo))
apiRateLimiter,
cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO),
asyncMiddleware(generateNodeinfo)
)
// robots.txt service // robots.txt service
miscRouter.get('/robots.txt', miscRouter.get('/robots.txt', apiRateLimiter, cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS), (_, res: express.Response) => {
apiRateLimiter, res.type('text/plain')
cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS),
(_, res: express.Response) => {
res.type('text/plain')
return res.send(CONFIG.INSTANCE.ROBOTS) return res.send(CONFIG.INSTANCE.ROBOTS)
} })
)
miscRouter.all('/teapot', miscRouter.all('/teapot', apiRateLimiter, getCup, asyncMiddleware(serveIndexHTML))
apiRateLimiter,
getCup,
asyncMiddleware(serveIndexHTML)
)
// security.txt service // security.txt service
miscRouter.get('/security.txt', miscRouter.get('/security.txt', apiRateLimiter, (_, res: express.Response) => {
apiRateLimiter, return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt')
(_, res: express.Response) => { })
return res.redirect(HttpStatusCode.MOVED_PERMANENTLY_301, '/.well-known/security.txt')
}
)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -56,7 +41,7 @@ export {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
async function generateNodeinfo (req: express.Request, res: express.Response) { async function generateNodeinfo (req: express.Request, res: express.Response) {
const { totalVideos } = await VideoModel.getStats() const { totalLocalVideos } = await VideoModel.getStats()
const { totalLocalVideoComments } = await VideoCommentModel.getStats() const { totalLocalVideoComments } = await VideoCommentModel.getStats()
const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
@ -90,7 +75,7 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
activeMonth: totalMonthlyActiveUsers, activeMonth: totalMonthlyActiveUsers,
activeHalfyear: totalHalfYearActiveUsers activeHalfyear: totalHalfYearActiveUsers
}, },
localPosts: totalVideos, localPosts: totalLocalVideos,
localComments: totalLocalVideoComments localComments: totalLocalVideoComments
}, },
metadata: { metadata: {
@ -196,8 +181,8 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
} as HttpNodeinfoDiasporaSoftwareNsSchema20 } as HttpNodeinfoDiasporaSoftwareNsSchema20
res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"')
.send(json) .send(json)
.end() .end()
} }
function getCup (req: express.Request, res: express.Response, next: express.NextFunction) { function getCup (req: express.Request, res: express.Response, next: express.NextFunction) {