Merge Masto Api changes
Co-authored-by Natty <natty.sh.git@gmail.com>
This commit is contained in:
parent
f331592d66
commit
b266b21b91
|
@ -1,6 +1,6 @@
|
||||||
import { ApiError } from "../../../error.js";
|
import { ApiError } from "../../../error.js";
|
||||||
import define from "../../../define.js";
|
import define from "../../../define.js";
|
||||||
import { RegistryItems } from "../../../../../models/index.js";
|
import {RegistryItems} from "@/models/index.js";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { apiAccountMastodon } from './endpoints/account.js';
|
||||||
import { apiStatusMastodon } from './endpoints/status.js';
|
import { apiStatusMastodon } from './endpoints/status.js';
|
||||||
import { apiFilterMastodon } from './endpoints/filter.js';
|
import { apiFilterMastodon } from './endpoints/filter.js';
|
||||||
import { apiTimelineMastodon } from './endpoints/timeline.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 { apiSearchMastodon } from './endpoints/search.js';
|
||||||
import { getInstance } from './endpoints/meta.js';
|
import { getInstance } from './endpoints/meta.js';
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export function apiMastodonCompatible(router: Router): void {
|
||||||
apiStatusMastodon(router)
|
apiStatusMastodon(router)
|
||||||
apiFilterMastodon(router)
|
apiFilterMastodon(router)
|
||||||
apiTimelineMastodon(router)
|
apiTimelineMastodon(router)
|
||||||
apiNotificationsMastodon(router)
|
apiNotificationMastodon(router)
|
||||||
apiSearchMastodon(router)
|
apiSearchMastodon(router)
|
||||||
|
|
||||||
router.get('/v1/custom_emojis', async (ctx) => {
|
router.get('/v1/custom_emojis', async (ctx) => {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import megalodon, { MegalodonInterface } from '@cutls/megalodon';
|
||||||
import Router from "@koa/router";
|
import Router from "@koa/router";
|
||||||
import { koaBody } from 'koa-body';
|
import { koaBody } from 'koa-body';
|
||||||
import { getClient } from '../ApiMastodonCompatibleService.js';
|
import { getClient } from '../ApiMastodonCompatibleService.js';
|
||||||
|
import bodyParser from "koa-bodyparser";
|
||||||
|
|
||||||
const readScope = [
|
const readScope = [
|
||||||
'read:account',
|
'read:account',
|
||||||
|
@ -42,7 +43,10 @@ const writeScope = [
|
||||||
|
|
||||||
export function apiAuthMastodon(router: Router): void {
|
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 BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
|
||||||
const accessTokens = ctx.request.headers.authorization;
|
const accessTokens = ctx.request.headers.authorization;
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { createTemp } from "@/misc/create-temp.js";
|
||||||
import { publishMainStream } from "@/services/stream.js";
|
import { publishMainStream } from "@/services/stream.js";
|
||||||
import * as Acct from "@/misc/acct.js";
|
import * as Acct from "@/misc/acct.js";
|
||||||
import { envOption } from "@/env.js";
|
import { envOption } from "@/env.js";
|
||||||
import { koaBody } from 'koa-body';
|
import {koaBody} from "koa-body";
|
||||||
import megalodon, { MegalodonInterface } from '@cutls/megalodon';
|
import megalodon, { MegalodonInterface } from '@cutls/megalodon';
|
||||||
import activityPub from "./activitypub.js";
|
import activityPub from "./activitypub.js";
|
||||||
import nodeinfo from "./nodeinfo.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());
|
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 body: any = ctx.request.body;
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue