From d43c6b1ffc5e6c895f9e9f9de6625f17a9755c20 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Jan 2021 14:13:23 +0100 Subject: Implement remote interaction --- server/controllers/webfinger.ts | 5 +++++ server/tests/misc-endpoints.ts | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'server') diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts index 5c308d9ad..885e4498f 100644 --- a/server/controllers/webfinger.ts +++ b/server/controllers/webfinger.ts @@ -1,5 +1,6 @@ import * as cors from 'cors' import * as express from 'express' +import { WEBSERVER } from '@server/initializers/constants' import { asyncMiddleware } from '../middlewares' import { webfingerValidator } from '../middlewares/validators' @@ -31,6 +32,10 @@ function webfingerController (req: express.Request, res: express.Response) { rel: 'self', type: 'application/activity+json', href: actor.url + }, + { + rel: 'http://ostatus.org/schema/1.0/subscribe', + template: WEBSERVER.URL + '/remote-interaction?uri={uri}' } ] } diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 162b53e18..09e5afcf9 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts @@ -80,6 +80,31 @@ describe('Test misc endpoints', function () { expect(res.header.location).to.equal('/my-account/settings') }) + + it('Should test webfinger', async function () { + const resource = 'acct:peertube@' + server.host + const accountUrl = server.url + '/accounts/peertube' + + const res = await makeGetRequest({ + url: server.url, + path: '/.well-known/webfinger?resource=' + resource, + statusCodeExpected: HttpStatusCode.OK_200 + }) + + const data = res.body + + expect(data.subject).to.equal(resource) + expect(data.aliases).to.contain(accountUrl) + + const self = data.links.find(l => l.rel === 'self') + expect(self).to.exist + expect(self.type).to.equal('application/activity+json') + expect(self.href).to.equal(accountUrl) + + const remoteInteract = data.links.find(l => l.rel === 'http://ostatus.org/schema/1.0/subscribe') + expect(remoteInteract).to.exist + expect(remoteInteract.template).to.equal(server.url + '/remote-interaction?uri={uri}') + }) }) describe('Test classic static endpoints', function () { -- cgit v1.2.3