Merge Masto Api changes

Co-authored-by Natty <natty.sh.git@gmail.com>
This commit is contained in:
cutestnekoaqua 2023-02-10 20:45:29 +01:00
parent 8ddfd9630c
commit 3f73e2ff84
4 changed files with 13 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { ApiError } from "../../../error.js";
import define from "../../../define.js";
import { RegistryItems } from "../../../../../models/index.js";
import {RegistryItems} from "@/models/index.js";
export const meta = {
requireCredential: true,

View File

@ -5,7 +5,7 @@ import { apiAccountMastodon } from './endpoints/account.js';
import { apiStatusMastodon } from './endpoints/status.js';
import { apiFilterMastodon } from './endpoints/filter.js';
import { apiTimelineMastodon } from './endpoints/timeline.js';
import { apiNotificationsMastodon } from './endpoints/notifications.js';
import { apiNotificationMastodon } from './endpoints/notifications.js';
import { apiSearchMastodon } from './endpoints/search.js';
import { getInstance } from './endpoints/meta.js';
@ -23,7 +23,7 @@ export function apiMastodonCompatible(router: Router): void {
apiStatusMastodon(router)
apiFilterMastodon(router)
apiTimelineMastodon(router)
apiNotificationsMastodon(router)
apiNotificationMastodon(router)
apiSearchMastodon(router)
router.get('/v1/custom_emojis', async (ctx) => {

View File

@ -2,6 +2,7 @@ import megalodon, { MegalodonInterface } from '@cutls/megalodon';
import Router from "@koa/router";
import { koaBody } from 'koa-body';
import { getClient } from '../ApiMastodonCompatibleService.js';
import bodyParser from "koa-bodyparser";
const readScope = [
'read:account',
@ -42,7 +43,10 @@ const writeScope = [
export function apiAuthMastodon(router: Router): void {
router.post('/v1/apps', koaBody(), async (ctx) => {
router.post('/v1/apps', koaBody({
json: false,
multipart: true
}), async (ctx) => {
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const accessTokens = ctx.request.headers.authorization;
const client = getClient(BASE_URL, accessTokens);

View File

@ -20,7 +20,7 @@ import { createTemp } from "@/misc/create-temp.js";
import { publishMainStream } from "@/services/stream.js";
import * as Acct from "@/misc/acct.js";
import { envOption } from "@/env.js";
import { koaBody } from 'koa-body';
import {koaBody} from "koa-body";
import megalodon, { MegalodonInterface } from '@cutls/megalodon';
import activityPub from "./activitypub.js";
import nodeinfo from "./nodeinfo.js";
@ -141,7 +141,10 @@ router.get("/oauth/authorize", async (ctx) => {
ctx.redirect(Buffer.from(client_id?.toString() || '', 'base64').toString());
});
router.get("/oauth/token", koaBody(), async (ctx) => {
router.post("/oauth/token", koaBody({
json: false,
multipart: true
}), async (ctx) => {
const body: any = ctx.request.body;
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const generator = (megalodon as any).default;