mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-28 12:57:31 -07:00
is this the proper way?
This commit is contained in:
parent
8a088b8d74
commit
8e7c6526e1
2 changed files with 34 additions and 22 deletions
|
@ -35,9 +35,6 @@ import { koaBody } from "koa-body";
|
||||||
import removeTrailingSlash from "koa-remove-trailing-slashes";
|
import removeTrailingSlash from "koa-remove-trailing-slashes";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
import { Cache } from "@/misc/cache.js";
|
import { Cache } from "@/misc/cache.js";
|
||||||
import { getInstance } from "./api/mastodon/endpoints/meta.js";
|
|
||||||
import { convertAccount } from "./api/mastodon/converters.js";
|
|
||||||
import { getClient } from "./api/mastodon/ApiMastodonCompatibleService.js";
|
|
||||||
|
|
||||||
export const serverLogger = new Logger("server", "gray", false);
|
export const serverLogger = new Logger("server", "gray", false);
|
||||||
|
|
||||||
|
@ -161,29 +158,13 @@ const cache = new Cache<Awaited<ReturnType<typeof nodeinfo2>>>(
|
||||||
|
|
||||||
mastoRouter.get("/nodeinfo/2.0.json", async (ctx) => {
|
mastoRouter.get("/nodeinfo/2.0.json", async (ctx) => {
|
||||||
const base = await cache.fetch(null, () => nodeinfo2());
|
const base = await cache.fetch(null, () => nodeinfo2());
|
||||||
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
|
||||||
const accessTokens = ctx.request.headers.authorization;
|
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
|
||||||
const data = await client.getInstance();
|
|
||||||
const admin = await Users.findOne({
|
|
||||||
where: {
|
|
||||||
host: IsNull(),
|
|
||||||
isAdmin: true,
|
|
||||||
isDeleted: false,
|
|
||||||
isSuspended: false,
|
|
||||||
},
|
|
||||||
order: { id: "ASC" },
|
|
||||||
});
|
|
||||||
const contact =
|
|
||||||
admin == null
|
|
||||||
? null
|
|
||||||
: convertAccount((await client.getAccount(admin.id)).data);
|
|
||||||
const masto = { ...getInstance(data.data, contact), ...base };
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
base.software.repository = undefined;
|
base.software.repository = undefined;
|
||||||
|
|
||||||
ctx.body = { version: "2.0", ...masto };
|
ctx.body = {
|
||||||
|
version: "2.0",
|
||||||
|
...base };
|
||||||
ctx.set("Cache-Control", "public, max-age=600");
|
ctx.set("Cache-Control", "public, max-age=600");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,37 @@ export const nodeinfo2 = async () => {
|
||||||
enableServiceWorker: meta.enableServiceWorker,
|
enableServiceWorker: meta.enableServiceWorker,
|
||||||
proxyAccountName: proxyAccount ? proxyAccount.username : null,
|
proxyAccountName: proxyAccount ? proxyAccount.username : null,
|
||||||
themeColor: meta.themeColor || "#31748f",
|
themeColor: meta.themeColor || "#31748f",
|
||||||
|
|
||||||
|
//Akkoma
|
||||||
|
features: [
|
||||||
|
"mastodon_api",
|
||||||
|
"mastodon_api_float",
|
||||||
|
"polls",
|
||||||
|
"relay",
|
||||||
|
"quote_posting",
|
||||||
|
"pleroma_emoji_reactions",
|
||||||
|
"pleroma_chat_messages",
|
||||||
|
"exposable_reactions",
|
||||||
|
"profile_directory"
|
||||||
|
],
|
||||||
|
federation: {
|
||||||
|
enabled : true
|
||||||
|
},
|
||||||
|
fields_limits: {
|
||||||
|
max_fields: 10,
|
||||||
|
max_remote_fields: 20,
|
||||||
|
name_length: 512,
|
||||||
|
value_length: 2048
|
||||||
|
},
|
||||||
|
post_formats: [
|
||||||
|
"text/x.misskeymarkdown"
|
||||||
|
],
|
||||||
|
publicTimelineVisibility: {
|
||||||
|
local: true,
|
||||||
|
federated: false,
|
||||||
|
bubble: false,
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue