mirror of
https://github.com/turbomaster95/coderrrrr.git
synced 2025-05-12 04:50:13 +00:00
update finger
This commit is contained in:
parent
37a2af1fd3
commit
889aa4b042
@ -1,35 +1,58 @@
|
|||||||
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
||||||
|
|
||||||
export default function (req: VercelRequest, res: VercelResponse) {
|
export default function (req: VercelRequest, res: VercelResponse) {
|
||||||
|
// Get the resource query parameter
|
||||||
const { resource } = req.query;
|
const { resource } = req.query;
|
||||||
res.statusCode = 200;
|
|
||||||
res.setHeader("Content-Type", `application/jrd+json`);
|
if (!resource || typeof resource !== "string") {
|
||||||
res.end(`{
|
res.status(400).json({ error: "Missing or invalid resource parameter" });
|
||||||
"subject": "acct:blog@coderrrrr.site",
|
return;
|
||||||
"aliases": [
|
}
|
||||||
"https://coderrrrr.site/blog",
|
|
||||||
"https://coderrrrr.site/@blog"
|
// Expected format: acct:username@coderrrrr.site
|
||||||
],
|
const match = resource.match(/^acct:([^@]+)@coderrrrr\.site$/i);
|
||||||
"links": [
|
if (!match) {
|
||||||
|
res.status(400).json({ error: "Resource format not supported" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ṣ
|
||||||
|
const username = match[1].toLowerCase();
|
||||||
|
|
||||||
|
// Determine the profile URL based on the username.
|
||||||
|
// For this example, we support only the "blog" account.
|
||||||
|
// You can add more supported usernames as needed.
|
||||||
|
let profileUrl: string;
|
||||||
|
if (username === "blog") {
|
||||||
|
profileUrl = "https://coderrrrr.site/blog";
|
||||||
|
} else {
|
||||||
|
// If the username is not recognized, return a 404.
|
||||||
|
res.status(404).json({ error: "User not found" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the WebFinger response object
|
||||||
|
const webfingerResponse = {
|
||||||
|
subject: resource,
|
||||||
|
aliases: [profileUrl],
|
||||||
|
links: [
|
||||||
{
|
{
|
||||||
"rel": "http://webfinger.net/rel/profile-page",
|
rel: "http://webfinger.net/rel/profile-page",
|
||||||
"type": "text/html",
|
type: "text/html",
|
||||||
"href": "https://coderrrrr.site/@blog"
|
href: profileUrl
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rel": "self",
|
rel: "self",
|
||||||
"type": "application/activity+json",
|
type: "application/activity+json",
|
||||||
"href": "https://coderrrrr.site/@blog"
|
href: profileUrl
|
||||||
},
|
},
|
||||||
|
// Optional: Add a subscription template if needed.
|
||||||
{
|
{
|
||||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
rel: "http://ostatus.org/schema/1.0/subscribe",
|
||||||
"template": "https://coderrrrr.site/authorize_interaction?uri={uri}"
|
template: "https://coderrrrr.site/authorize_interaction?uri={uri}"
|
||||||
},
|
|
||||||
{
|
|
||||||
"rel": "http://webfinger.net/rel/avatar",
|
|
||||||
"type": "image/png",
|
|
||||||
"href": "https://files.usr.cloud/v1/AUTH_f22cbcf5b3904990be9696691ff73fc6/files.usr.cloud/accounts/avatars/113/822/701/816/479/941/original/7d7f6088ba1ddd57.png"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}`);
|
};
|
||||||
|
|
||||||
|
res.setHeader("Content-Type", "application/jrd+json");
|
||||||
|
res.status(200).json(webfingerResponse);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user