[mastodon-client] megalodon compat changes

This commit is contained in:
Laura Hausmann 2023-07-02 18:41:01 +02:00 committed by Laura Hausmann
parent 8cf7a24e9f
commit 1f8c735889
6 changed files with 14 additions and 18 deletions

View File

@ -18,11 +18,7 @@ export function getClient(
const accessTokenArr = authorization?.split(" ") ?? [null];
const accessToken = accessTokenArr[accessTokenArr.length - 1];
const generator = (megalodon as any).default;
const client = generator(
"misskey",
BASE_URL,
accessToken,
) as MegalodonInterface;
const client = generator(BASE_URL, accessToken) as MegalodonInterface;
return client;
}

View File

@ -42,8 +42,8 @@ export function apiAccountMastodon(router: Router): void {
acct.url = `${BASE_URL}/@${acct.url}`;
acct.note = acct.note || "";
acct.avatar_static = acct.avatar;
acct.header = acct.header || "https://http.cat/404";
acct.header_static = acct.header || "https://http.cat/404";
acct.header = acct.header || "/static-assets/transparent.png";
acct.header_static = acct.header || "/static-assets/transparent.png";
acct.source = {
note: acct.note,
fields: acct.fields,

View File

@ -24,7 +24,7 @@ export async function getInstance(response: Entity.Instance) {
status_count: await totalStatuses,
domain_count: response.stats.domain_count,
},
thumbnail: response.thumbnail || "https://http.cat/404",
thumbnail: response.thumbnail || "/static-assets/transparent.png",
languages: meta.langs,
registrations: !meta.disableRegistration || response.registrations,
approval_required: !response.registrations,
@ -96,8 +96,8 @@ export async function getInstance(response: Entity.Instance) {
url: `${response.uri}/`,
avatar: `${response.uri}/static-assets/badges/info.png`,
avatar_static: `${response.uri}/static-assets/badges/info.png`,
header: "https://http.cat/404",
header_static: "https://http.cat/404",
header: "/static-assets/transparent.png",
header_static: "/static-assets/transparent.png",
followers_count: -1,
following_count: 0,
statuses_count: 0,

View File

@ -103,7 +103,7 @@ async function getHighlight(
i: accessToken,
});
const data: MisskeyEntity.Note[] = api.data;
return data.map((note) => Converter.note(note, domain));
return data.map((note) => new Converter(BASE_URL).note(note, domain));
} catch (e: any) {
console.log(e);
console.log(e.response.data);
@ -131,7 +131,7 @@ async function getFeaturedUser(
return data.map((u) => {
return {
source: "past_interactions",
account: Converter.userDetail(u, host),
account: new Converter(BASE_URL).userDetail(u, host),
};
});
} catch (e: any) {

View File

@ -449,8 +449,8 @@ export function statusModel(
const now = new Date().toISOString();
return {
id: "9atm5frjhb",
uri: "https://http.cat/404", // ""
url: "https://http.cat/404", // "",
uri: "/static-assets/transparent.png", // ""
url: "/static-assets/transparent.png", // "",
account: {
id: "9arzuvv0sw",
username: "Reactions",
@ -462,11 +462,11 @@ export function statusModel(
following_count: 0,
statuses_count: 0,
note: "",
url: "https://http.cat/404",
url: "/static-assets/transparent.png",
avatar: "/static-assets/badges/info.png",
avatar_static: "/static-assets/badges/info.png",
header: "https://http.cat/404", // ""
header_static: "https://http.cat/404", // ""
header: "/static-assets/transparent.png", // ""
header_static: "/static-assets/transparent.png", // ""
emojis: [],
fields: [],
moved: null,

View File

@ -166,7 +166,7 @@ mastoRouter.post("/oauth/token", async (ctx) => {
let client_id: any = body.client_id;
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const generator = (megalodon as any).default;
const client = generator("misskey", BASE_URL, null) as MegalodonInterface;
const client = generator(BASE_URL, null) as MegalodonInterface;
let m = null;
let token = null;
if (body.code) {