wip
This commit is contained in:
@@ -7,34 +7,10 @@ import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { AppEntityService } from '@/core/entities/AppEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['app'],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'App',
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
description: { type: 'string' },
|
||||
permission: { type: 'array', uniqueItems: true, items: {
|
||||
type: 'string',
|
||||
} },
|
||||
callbackUrl: { type: 'string', nullable: true },
|
||||
},
|
||||
required: ['name', 'description', 'permission'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
export default class extends Endpoint<'app/create'> {
|
||||
name = 'app/create' as const;
|
||||
constructor(
|
||||
@Inject(DI.appsRepository)
|
||||
private appsRepository: AppsRepository,
|
||||
@@ -42,7 +18,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
private appEntityService: AppEntityService,
|
||||
private idService: IdService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
super(async (ps, me) => {
|
||||
// Generate secret
|
||||
const secret = secureRndstr(32, true);
|
||||
|
||||
|
@@ -5,49 +5,24 @@ import { AppEntityService } from '@/core/entities/AppEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['app'],
|
||||
|
||||
errors: {
|
||||
noSuchApp: {
|
||||
message: 'No such app.',
|
||||
code: 'NO_SUCH_APP',
|
||||
id: 'dce83913-2dc6-4093-8a7b-71dbb11718a3',
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'App',
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
appId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['appId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
export default class extends Endpoint<'app/show'> {
|
||||
name = 'app/show' as const;
|
||||
constructor(
|
||||
@Inject(DI.appsRepository)
|
||||
private appsRepository: AppsRepository,
|
||||
|
||||
private appEntityService: AppEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, user, token) => {
|
||||
super(async (ps, user, token) => {
|
||||
const isSecure = user != null && token == null;
|
||||
|
||||
// Lookup app
|
||||
const ap = await this.appsRepository.findOneBy({ id: ps.appId });
|
||||
|
||||
if (ap == null) {
|
||||
throw new ApiError(meta.errors.noSuchApp);
|
||||
throw new ApiError(this.meta.errors.noSuchApp);
|
||||
}
|
||||
|
||||
return await this.appEntityService.pack(ap, user, {
|
||||
|
Reference in New Issue
Block a user