summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-08-15 00:04:57 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-08-15 00:04:57 +1000
commitff7f520ca39a114f30da631cc3d4db92dbf2f875 (patch)
treee23f34d804a6d713c63dd75ea13e9234bf2e22b1 /scripts
parentmmm bodyparser (diff)
downloadserver-ts-ff7f520ca39a114f30da631cc3d4db92dbf2f875.tar.xz
garbage
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ap/get.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/ap/get.js b/scripts/ap/get.js
new file mode 100644

index 00000000..ab235427 --- /dev/null +++ b/scripts/ap/get.js
@@ -0,0 +1,34 @@ +const nodeFetch = require("node-fetch"); + +const fetch = (url, opts) => + nodeFetch(url, { + ...opts, + headers: { + Accept: "application/activity+json", + ...(opts?.headers || {}), + }, + }).then((x) => x.json()); + +const webfinger = async (domain, user) => { + const query = `https://${domain}/.well-known/webfinger?resource=@${user}@${domain}`; + const json = await fetch(query); + return json.links.find((x) => x.rel == "self").href; +}; + +(async () => { + const userLocation = await webfinger( + "chat.understars.dev", + "1140599542186631381", + ); + console.log(userLocation); + + const user = await fetch(userLocation); + + const outbox = await fetch(user.outbox); + + const firstPage = await fetch(outbox.first); + + const mostRecent = firstPage.orderedItems[0]; + + console.log(mostRecent); +})();