From 531166a35db2c19a26d34a1988393584a5c2f8f4 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 6 May 2023 20:32:06 +0200 Subject: [PATCH] docs: remove social integration --- website/api/webfinger/function.json | 18 ------- website/api/webfinger/index.js | 83 ----------------------------- website/staticwebapp.config.json | 14 +---- 3 files changed, 1 insertion(+), 114 deletions(-) delete mode 100644 website/api/webfinger/function.json delete mode 100644 website/api/webfinger/index.js diff --git a/website/api/webfinger/function.json b/website/api/webfinger/function.json deleted file mode 100644 index c7642f69..00000000 --- a/website/api/webfinger/function.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "bindings": [ - { - "authLevel": "anonymous", - "type": "httpTrigger", - "direction": "in", - "name": "req", - "methods": [ - "get" - ] - }, - { - "type": "http", - "direction": "out", - "name": "res" - } - ] -} diff --git a/website/api/webfinger/index.js b/website/api/webfinger/index.js deleted file mode 100644 index df2a0dd8..00000000 --- a/website/api/webfinger/index.js +++ /dev/null @@ -1,83 +0,0 @@ -// GET https://${MASTODON_DOMAIN}/.well-known/webfinger?resource=acct:${MASTODON_USER}@${MASTODON_DOMAIN} - -function trimPrefix(str, prefix) { - if (str.startsWith(prefix)) { - return str.slice(prefix.length) - } - return str -} - -function webfinger(username) { - return { - "subject": `acct:${username}@hachyderm.io`, - "aliases": [ - `https://hachyderm.io/@${username}`, - `https://hachyderm.io/users/${username}` - ], - "links": [ - { - "rel": "http://webfinger.net/rel/profile-page", - "type": "text/html", - "href": `https://hachyderm.io/@${username}` - }, - { - "rel": "self", - "type": "application/activity+json", - "href": `https://hachyderm.io/users/${username}` - }, - { - "rel": "http://ostatus.org/schema/1.0/subscribe", - "template": "https://hachyderm.io/authorize_interaction?uri={uri}" - } - ] - }; -} - -module.exports = async function (context, req) { - context.log('Webfinger function processed a request'); - - try { - let resource = req.query.resource; - if (!resource) { - resource = "jan@social.ohmyposh.dev"; - } - - resource = trimPrefix(resource, "acct:"); - - context.log(`Creating Mastodon user info for ${resource}`); - - let body; - - switch (resource) { - case "releasebot@social.ohmyposh.dev": - body = webfinger("releasebot"); - break; - case "jan@social.ohmyposh.dev": - body = webfinger("jandedobbeleer"); - break; - default: - context.log(`Unknown resource: ${resource}`); - context.res = { - body: "Unknown resource", - status: 400 - }; - return; - } - - // return body as application/jrd+json - context.res = { - body: body, - headers: { - "Content-Type": "application/jrd+json" - } - }; - } catch (error) { - context.log(error); - context.res = { - body: { - "message": (error.message) ? error.message : "unable to create webfinger" - }, - status: 500 - }; - } -} diff --git a/website/staticwebapp.config.json b/website/staticwebapp.config.json index 8c41283b..1a262873 100644 --- a/website/staticwebapp.config.json +++ b/website/staticwebapp.config.json @@ -1,17 +1,5 @@ { "platform": { "apiRuntime": "node:16" - }, - "routes": [ - { - "route": "/.well-known/webfinger*", - "methods": ["GET"], - "rewrite": "/api/webfinger" - }, - { - "route": "/@jan", - "methods": ["GET"], - "redirect": "https://hachyderm.io/@jandedobbeleer" - } - ] + } }