mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
feature: initial syndication feeds support
Provides rss 2.0, atom 1.0 and json 1.0 feeds for videos (instance and account-wide) on listings and video-watch views. * still lacks redis caching * still lacks lastBuildDate support * still lacks channel-wide support * still lacks semantic annotation (for licenses, NSFW warnings, etc.) * still lacks love ( ˘ ³˘) * RSS: has MRSS support for torrent lists! * RSS: includes the first torrent in an enclosure * JSON: lists all torrents in the 'attachments' object * ATOM: lacking torrent listing support Advances #23 Partial implementation for the accountId generation in the client, which will need a hotfix to add a way to get the proper account id.
This commit is contained in:
parent
c36d5a6b98
commit
244e76a552
33 changed files with 608 additions and 84 deletions
35
server/middlewares/validators/feeds.ts
Normal file
35
server/middlewares/validators/feeds.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import * as express from 'express'
|
||||
import { param, query } from 'express-validator/check'
|
||||
import { isAccountIdExist, isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
|
||||
import { join } from 'path'
|
||||
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
|
||||
|
||||
const feedsValidator = [
|
||||
param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
|
||||
query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
|
||||
query('accountId').optional().custom(isIdOrUUIDValid),
|
||||
query('accountName').optional().custom(isAccountNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking feeds parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (req.query.accountId) {
|
||||
if (!await isAccountIdExist(req.query.accountId, res)) return
|
||||
} else if (req.query.accountName) {
|
||||
if (!await isLocalAccountNameExist(req.query.accountName, res)) return
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
]
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
feedsValidator
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue