Fix well known and json parser with mastodon
This commit is contained in:
parent
14063e9656
commit
165cdc75bf
|
@ -76,7 +76,10 @@ app.use(morgan('combined', {
|
||||||
stream: { write: logger.info }
|
stream: { write: logger.info }
|
||||||
}))
|
}))
|
||||||
// For body requests
|
// For body requests
|
||||||
app.use(bodyParser.json({ limit: '500kb' }))
|
app.use(bodyParser.json({
|
||||||
|
type: 'application/*+json',
|
||||||
|
limit: '500kb'
|
||||||
|
}))
|
||||||
app.use(bodyParser.urlencoded({ extended: false }))
|
app.use(bodyParser.urlencoded({ extended: false }))
|
||||||
|
|
||||||
// ----------- Tracker -----------
|
// ----------- Tracker -----------
|
||||||
|
|
|
@ -27,6 +27,7 @@ function webfingerController (req: express.Request, res: express.Response, next:
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
rel: 'self',
|
rel: 'self',
|
||||||
|
type: 'application/activity+json',
|
||||||
href: account.url
|
href: account.url
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -219,7 +219,11 @@ const VIDEO_MIMETYPE_EXT = {
|
||||||
const SERVER_ACCOUNT_NAME = 'peertube'
|
const SERVER_ACCOUNT_NAME = 'peertube'
|
||||||
|
|
||||||
const ACTIVITY_PUB = {
|
const ACTIVITY_PUB = {
|
||||||
ACCEPT_HEADER: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
ACCEPT_HEADERS: [
|
||||||
|
'application/activity+json, application/ld+json',
|
||||||
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
|
||||||
|
],
|
||||||
|
ACCEPT_HEADER: '',
|
||||||
PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
|
PUBLIC: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
COLLECTION_ITEMS_PER_PAGE: 10,
|
COLLECTION_ITEMS_PER_PAGE: 10,
|
||||||
FETCH_PAGE_LIMIT: 100,
|
FETCH_PAGE_LIMIT: 100,
|
||||||
|
@ -230,6 +234,7 @@ const ACTIVITY_PUB = {
|
||||||
MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
|
MAGNET: [ 'application/x-bittorrent;x-scheme-handler/magnet' ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ACTIVITY_PUB.ACCEPT_HEADER = ACTIVITY_PUB.ACCEPT_HEADERS[0]
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ const sequelize = new Sequelize(dbname, username, password, {
|
||||||
operatorsAliases: false,
|
operatorsAliases: false,
|
||||||
|
|
||||||
logging: (message: string, benchmark: number) => {
|
logging: (message: string, benchmark: number) => {
|
||||||
|
if (process.env.NODE_DB_LOG === 'false') return
|
||||||
|
|
||||||
let newMessage = message
|
let newMessage = message
|
||||||
if (isTestInstance() === true && benchmark !== undefined) {
|
if (isTestInstance() === true && benchmark !== undefined) {
|
||||||
newMessage += ' | ' + benchmark + 'ms'
|
newMessage += ' | ' + benchmark + 'ms'
|
||||||
|
|
|
@ -37,10 +37,12 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
|
||||||
|
|
||||||
function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
|
function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
|
||||||
return (req: Request, res: Response, next: NextFunction) => {
|
return (req: Request, res: Response, next: NextFunction) => {
|
||||||
if (req.header('Accept') !== ACTIVITY_PUB.ACCEPT_HEADER) {
|
if (ACTIVITY_PUB.ACCEPT_HEADERS.indexOf(req.header('Accept')) === -1) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug('ActivityPub request for %s.', req.url)
|
||||||
|
|
||||||
if (Array.isArray(fun) === true) {
|
if (Array.isArray(fun) === true) {
|
||||||
return eachSeries(fun as RequestHandler[], (f, cb) => {
|
return eachSeries(fun as RequestHandler[], (f, cb) => {
|
||||||
f(req, res, cb)
|
f(req, res, cb)
|
||||||
|
|
|
@ -616,6 +616,13 @@ toActivityPubObject = function (this: VideoInstance) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add video url too
|
||||||
|
url.push({
|
||||||
|
type: 'Link',
|
||||||
|
mimeType: 'text/html',
|
||||||
|
url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
|
||||||
|
})
|
||||||
|
|
||||||
const videoObject: VideoTorrentObject = {
|
const videoObject: VideoTorrentObject = {
|
||||||
type: 'Video' as 'Video',
|
type: 'Video' as 'Video',
|
||||||
id: this.url,
|
id: this.url,
|
||||||
|
|
|
@ -471,9 +471,9 @@ bitcore-lib@^0.13.7:
|
||||||
inherits "=2.0.1"
|
inherits "=2.0.1"
|
||||||
lodash "=3.10.1"
|
lodash "=3.10.1"
|
||||||
|
|
||||||
"bitcore-message@github:comakery/bitcore-message#dist":
|
"bitcore-message@github:CoMakery/bitcore-message#dist":
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://codeload.github.com/comakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"
|
resolved "https://codeload.github.com/CoMakery/bitcore-message/tar.gz/8799cc327029c3d34fc725f05b2cf981363f6ebf"
|
||||||
dependencies:
|
dependencies:
|
||||||
bitcore-lib "^0.13.7"
|
bitcore-lib "^0.13.7"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue