spec(profile): 相互リンク機能のロールによる制御の仕様変更 (MisskeyIO#701)
This commit is contained in:
parent
80389a9140
commit
09c419e11b
11 changed files with 61 additions and 43 deletions
|
@ -117,6 +117,12 @@ export const meta = {
|
|||
id: 'bf326f31-d430-4f97-9933-5d61e4d48a23',
|
||||
},
|
||||
|
||||
invalidUrl: {
|
||||
message: 'Invalid URL',
|
||||
code: 'INVALID_URL',
|
||||
id: 'b2452e00-2bd0-4da8-a2d0-972859da7358',
|
||||
},
|
||||
|
||||
forbiddenToSetYourself: {
|
||||
message: 'You can\'t set yourself as your own alias.',
|
||||
code: 'FORBIDDEN_TO_SET_YOURSELF',
|
||||
|
@ -228,12 +234,14 @@ export const paramDef = {
|
|||
},
|
||||
mutualLinkSections: {
|
||||
type: 'array',
|
||||
maxItems: 10,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string', nullable: true },
|
||||
mutualLinks: {
|
||||
type: 'array',
|
||||
maxItems: 30,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
@ -359,24 +367,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
if (ps.mutualLinkSections) {
|
||||
if (ps.mutualLinkSections.length > policy.mutualLinkSectionLimit) {
|
||||
throw new ApiError(meta.errors.restrictedByRole);
|
||||
}
|
||||
|
||||
const mutualLinkSections = ps.mutualLinkSections.map(async (section) => {
|
||||
if (section.mutualLinks.length > policy.mutualLinkLimit) {
|
||||
throw new ApiError(meta.errors.restrictedByRole);
|
||||
}
|
||||
|
||||
const mutualLinks = await Promise.all(section.mutualLinks.map(async (mutualLink) => {
|
||||
const file = await this.driveFilesRepository.findOneBy({ id: mutualLink.fileId });
|
||||
if (!RegExp(/^https?:\/\//).test(mutualLink.url)) throw new ApiError(meta.errors.invalidUrl);
|
||||
|
||||
if (!file) {
|
||||
throw new ApiError(meta.errors.noSuchFile);
|
||||
}
|
||||
if (!file.type.startsWith('image/')) {
|
||||
throw new ApiError(meta.errors.fileNotAnImage);
|
||||
}
|
||||
const file = await this.driveFilesRepository.findOneBy({ id: mutualLink.fileId });
|
||||
if (!file) throw new ApiError(meta.errors.noSuchFile);
|
||||
if (!file.type.startsWith("image/")) throw new ApiError(meta.errors.fileNotAnImage);
|
||||
|
||||
return {
|
||||
id: this.idService.gen(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue