-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement Host-Meta Lookup for Social Inbox (#15) #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind rebasing off of the latest code, too?
src/server/apsystem.ts
Outdated
throw new Error(`Cannot fetch host-meta data from ${hostMetaURL}: http status ${hostMetaResponse.status}`) | ||
} | ||
|
||
const hostMeta: HostMeta = await hostMetaResponse.json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Host-meta isn't JSON, we need to add an XML parser.
Try this library: https://github.com/NaturalIntelligence/fast-xml-parser/blob/HEAD/docs/v4/2.XMLparseOptions.md
Here's an example XML doc: https://github.com/RangerMauve/staticpub.mauve.moe/blob/default/.well-known/host-meta
c7117b7
to
b9731be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress, lets just add a test to make sure it works.
src/server/apsystem.test.ts
Outdated
@@ -133,6 +133,21 @@ test('getActor uses regular fetch when fromActor is not provided', async t => { | |||
}, 'getActor should use regular fetch when fromActor is not provided') | |||
}) | |||
|
|||
// Test for successful Webfinger fetch | |||
test('mentionToActor successfully fetches data from Webfinger', async t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind modifying this test to also stub out the host-meta file?
Try storing the actual webmention at /.well-known/webfinger/acct:[email protected]
and the following for the host-meta file:
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="https://domain.com/.well-known/webfinge/{uri}"/>
</XRD>
This will help us know whether the parsing works for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thank you 👍👍
#15