Add Misskey (untested)

This commit is contained in:
Nikita Karamov 2023-03-18 04:44:48 +01:00
parent cb0fc3e11d
commit 4dfe43918f
No known key found for this signature in database
GPG Key ID: 41D6F71EE78E77CD
1 changed files with 28 additions and 1 deletions

View File

@ -89,6 +89,33 @@ const PROJECTS: Map<string, FediverseProject> = new Map([
},
},
],
[
"misskey",
{
check: async (url: string): Promise<string> => {
const response = await fetch(new URL("/api/meta", url), {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
detail: false,
}),
});
const metadata = await response.json();
if (metadata.version) {
return "misskey";
}
throw new Error(`${url} doesn't host Misskey`);
},
checkUrl: "/",
publishEndpoint: "share",
params: {
text: "text",
},
},
],
]);
const checkProjectUrl = (
@ -113,7 +140,7 @@ const checkProjectUrl = (
export const get: APIRoute = async ({ params }) => {
const host = params.host as string;
const promises = Object.entries(PROJECTS).map(([service, project]) => {
const promises = [...PROJECTS.entries()].map(([service, project]) => {
const url = normalizeURL(host);
if (project.check !== undefined) {
return project.check(url);