mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-14 14:07:38 -07:00
[mastodon-client] megalodon compat changes
This commit is contained in:
parent
8cf7a24e9f
commit
1f8c735889
6 changed files with 14 additions and 18 deletions
|
@ -18,11 +18,7 @@ export function getClient(
|
||||||
const accessTokenArr = authorization?.split(" ") ?? [null];
|
const accessTokenArr = authorization?.split(" ") ?? [null];
|
||||||
const accessToken = accessTokenArr[accessTokenArr.length - 1];
|
const accessToken = accessTokenArr[accessTokenArr.length - 1];
|
||||||
const generator = (megalodon as any).default;
|
const generator = (megalodon as any).default;
|
||||||
const client = generator(
|
const client = generator(BASE_URL, accessToken) as MegalodonInterface;
|
||||||
"misskey",
|
|
||||||
BASE_URL,
|
|
||||||
accessToken,
|
|
||||||
) as MegalodonInterface;
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
acct.url = `${BASE_URL}/@${acct.url}`;
|
acct.url = `${BASE_URL}/@${acct.url}`;
|
||||||
acct.note = acct.note || "";
|
acct.note = acct.note || "";
|
||||||
acct.avatar_static = acct.avatar;
|
acct.avatar_static = acct.avatar;
|
||||||
acct.header = acct.header || "https://http.cat/404";
|
acct.header = acct.header || "/static-assets/transparent.png";
|
||||||
acct.header_static = acct.header || "https://http.cat/404";
|
acct.header_static = acct.header || "/static-assets/transparent.png";
|
||||||
acct.source = {
|
acct.source = {
|
||||||
note: acct.note,
|
note: acct.note,
|
||||||
fields: acct.fields,
|
fields: acct.fields,
|
||||||
|
|
|
@ -24,7 +24,7 @@ export async function getInstance(response: Entity.Instance) {
|
||||||
status_count: await totalStatuses,
|
status_count: await totalStatuses,
|
||||||
domain_count: response.stats.domain_count,
|
domain_count: response.stats.domain_count,
|
||||||
},
|
},
|
||||||
thumbnail: response.thumbnail || "https://http.cat/404",
|
thumbnail: response.thumbnail || "/static-assets/transparent.png",
|
||||||
languages: meta.langs,
|
languages: meta.langs,
|
||||||
registrations: !meta.disableRegistration || response.registrations,
|
registrations: !meta.disableRegistration || response.registrations,
|
||||||
approval_required: !response.registrations,
|
approval_required: !response.registrations,
|
||||||
|
@ -96,8 +96,8 @@ export async function getInstance(response: Entity.Instance) {
|
||||||
url: `${response.uri}/`,
|
url: `${response.uri}/`,
|
||||||
avatar: `${response.uri}/static-assets/badges/info.png`,
|
avatar: `${response.uri}/static-assets/badges/info.png`,
|
||||||
avatar_static: `${response.uri}/static-assets/badges/info.png`,
|
avatar_static: `${response.uri}/static-assets/badges/info.png`,
|
||||||
header: "https://http.cat/404",
|
header: "/static-assets/transparent.png",
|
||||||
header_static: "https://http.cat/404",
|
header_static: "/static-assets/transparent.png",
|
||||||
followers_count: -1,
|
followers_count: -1,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
statuses_count: 0,
|
statuses_count: 0,
|
||||||
|
|
|
@ -103,7 +103,7 @@ async function getHighlight(
|
||||||
i: accessToken,
|
i: accessToken,
|
||||||
});
|
});
|
||||||
const data: MisskeyEntity.Note[] = api.data;
|
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) {
|
} catch (e: any) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log(e.response.data);
|
console.log(e.response.data);
|
||||||
|
@ -131,7 +131,7 @@ async function getFeaturedUser(
|
||||||
return data.map((u) => {
|
return data.map((u) => {
|
||||||
return {
|
return {
|
||||||
source: "past_interactions",
|
source: "past_interactions",
|
||||||
account: Converter.userDetail(u, host),
|
account: new Converter(BASE_URL).userDetail(u, host),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
|
|
@ -449,8 +449,8 @@ export function statusModel(
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
return {
|
return {
|
||||||
id: "9atm5frjhb",
|
id: "9atm5frjhb",
|
||||||
uri: "https://http.cat/404", // ""
|
uri: "/static-assets/transparent.png", // ""
|
||||||
url: "https://http.cat/404", // "",
|
url: "/static-assets/transparent.png", // "",
|
||||||
account: {
|
account: {
|
||||||
id: "9arzuvv0sw",
|
id: "9arzuvv0sw",
|
||||||
username: "Reactions",
|
username: "Reactions",
|
||||||
|
@ -462,11 +462,11 @@ export function statusModel(
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
statuses_count: 0,
|
statuses_count: 0,
|
||||||
note: "",
|
note: "",
|
||||||
url: "https://http.cat/404",
|
url: "/static-assets/transparent.png",
|
||||||
avatar: "/static-assets/badges/info.png",
|
avatar: "/static-assets/badges/info.png",
|
||||||
avatar_static: "/static-assets/badges/info.png",
|
avatar_static: "/static-assets/badges/info.png",
|
||||||
header: "https://http.cat/404", // ""
|
header: "/static-assets/transparent.png", // ""
|
||||||
header_static: "https://http.cat/404", // ""
|
header_static: "/static-assets/transparent.png", // ""
|
||||||
emojis: [],
|
emojis: [],
|
||||||
fields: [],
|
fields: [],
|
||||||
moved: null,
|
moved: null,
|
||||||
|
|
|
@ -166,7 +166,7 @@ mastoRouter.post("/oauth/token", async (ctx) => {
|
||||||
let client_id: any = body.client_id;
|
let client_id: any = body.client_id;
|
||||||
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
||||||
const generator = (megalodon as any).default;
|
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 m = null;
|
||||||
let token = null;
|
let token = null;
|
||||||
if (body.code) {
|
if (body.code) {
|
||||||
|
|
Loading…
Reference in a new issue