fix(federation): 🐛 Re-add ability to query WebFinger on a different server than the queries resources's hostname

This commit is contained in:
Jesse Wierzbinski 2024-07-26 18:03:22 +02:00
parent 97826e18a9
commit 9b4ce7183a
No known key found for this signature in database

View file

@ -67,6 +67,7 @@ export class FederationRequester {
* @param username The username to get the profile link for.
* @param hostname The hostname to get the profile link for (defaults to the server's hostname).
* @param contentType The content type of the link to get (defaults to "application/json").
* @param serverUrl The URL of the server to query for WebFinger. Useful for bridges. Defaults to hostname.
* @returns The user's profile link.
* @throws If the request fails or the response is invalid.
* @example
@ -79,13 +80,14 @@ export class FederationRequester {
username: string,
hostname: string,
contentType = "application/json",
serverUrl = `https://${hostname}`,
): Promise<string> {
const result = await this.get<User>(
new URL(
`/.well-known/webfinger?${new URLSearchParams({
resource: `acct:${username}@${hostname}`,
})}`,
`https://${hostname}`,
serverUrl,
),
);