aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/activitypub.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-19 10:34:56 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commite12a009254de33bcdbd8334992980fa029c3e10d (patch)
tree85c6b576d9f76fee33b22e1fdbdca5e9daa24d50 /server/middlewares/activitypub.ts
parentce33ee01cd3806201b676c318e9aa930032921b2 (diff)
downloadPeerTube-e12a009254de33bcdbd8334992980fa029c3e10d.tar.gz
PeerTube-e12a009254de33bcdbd8334992980fa029c3e10d.tar.zst
PeerTube-e12a009254de33bcdbd8334992980fa029c3e10d.zip
Status are sent to mastodon
Diffstat (limited to 'server/middlewares/activitypub.ts')
-rw-r--r--server/middlewares/activitypub.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 37b7c42ec..9113e02a7 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -9,11 +9,13 @@ import { ActorModel } from '../models/activitypub/actor'
9async function checkSignature (req: Request, res: Response, next: NextFunction) { 9async function checkSignature (req: Request, res: Response, next: NextFunction) {
10 const signatureObject: ActivityPubSignature = req.body.signature 10 const signatureObject: ActivityPubSignature = req.body.signature
11 11
12 logger.debug('Checking signature of actor %s...', signatureObject.creator) 12 const [ creator ] = signatureObject.creator.split('#')
13
14 logger.debug('Checking signature of actor %s...', creator)
13 15
14 let actor: ActorModel 16 let actor: ActorModel
15 try { 17 try {
16 actor = await getOrCreateActorAndServerAndModel(signatureObject.creator) 18 actor = await getOrCreateActorAndServerAndModel(creator)
17 } catch (err) { 19 } catch (err) {
18 logger.error('Cannot create remote actor and check signature.', err) 20 logger.error('Cannot create remote actor and check signature.', err)
19 return res.sendStatus(403) 21 return res.sendStatus(403)
@@ -32,6 +34,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
32function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { 34function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
33 return (req: Request, res: Response, next: NextFunction) => { 35 return (req: Request, res: Response, next: NextFunction) => {
34 const accepted = req.accepts(ACCEPT_HEADERS) 36 const accepted = req.accepts(ACCEPT_HEADERS)
37 console.log(accepted)
35 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { 38 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
36 return next() 39 return next()
37 } 40 }