wip
This commit is contained in:
parent
8bad11c559
commit
f651ca4b48
3 changed files with 90 additions and 79 deletions
|
@ -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, {
|
||||
|
|
|
@ -2179,19 +2179,25 @@ export const endpoints = {
|
|||
{ type: 'null' },
|
||||
],
|
||||
},
|
||||
keywords: { type: 'array', items: {
|
||||
keywords: {
|
||||
type: 'array', items: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
},
|
||||
} },
|
||||
excludeKeywords: { type: 'array', items: {
|
||||
}
|
||||
},
|
||||
excludeKeywords: {
|
||||
type: 'array', items: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
},
|
||||
} },
|
||||
users: { type: 'array', items: {
|
||||
}
|
||||
},
|
||||
users: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
}
|
||||
},
|
||||
caseSensitive: { type: 'boolean' },
|
||||
withReplies: { type: 'boolean' },
|
||||
withFile: { type: 'boolean' },
|
||||
|
@ -2281,6 +2287,60 @@ export const endpoints = {
|
|||
],
|
||||
},
|
||||
}],
|
||||
},
|
||||
//#endregion
|
||||
|
||||
//#region app
|
||||
'app/create': {
|
||||
tags: ['app'],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
description: { type: 'string' },
|
||||
permission: {
|
||||
type: 'array',
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
callbackUrl: { type: ['string', 'null'] },
|
||||
} as const satisfies Record<string, JSONSchema7>,
|
||||
required: ['name', 'description', 'permission'],
|
||||
},
|
||||
res: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/App',
|
||||
},
|
||||
}],
|
||||
},
|
||||
'app/show': {
|
||||
tags: ['app'],
|
||||
|
||||
errors: {
|
||||
noSuchApp: {
|
||||
message: 'No such app.',
|
||||
code: 'NO_SUCH_APP',
|
||||
id: 'dce83913-2dc6-4093-8a7b-71dbb11718a3',
|
||||
},
|
||||
},
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
appId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['appId'],
|
||||
},
|
||||
res: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/App',
|
||||
},
|
||||
}],
|
||||
}
|
||||
//#endregion
|
||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||
|
|
Loading…
Reference in a new issue