From 09c419e11b198c27a50ad8b9437cb612aaa34880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 14 Aug 2024 20:04:06 +0900 Subject: [PATCH] =?UTF-8?q?spec(profile):=20=E7=9B=B8=E4=BA=92=E3=83=AA?= =?UTF-8?q?=E3=83=B3=E3=82=AF=E6=A9=9F=E8=83=BD=E3=81=AE=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=AB=E3=82=88=E3=82=8B=E5=88=B6=E5=BE=A1=E3=81=AE?= =?UTF-8?q?=E4=BB=95=E6=A7=98=E5=A4=89=E6=9B=B4=20(MisskeyIO#701)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en-US.yml | 1 + locales/index.d.ts | 4 ++ locales/ja-JP.yml | 1 + locales/ko-KR.yml | 3 +- packages/backend/src/core/RoleService.ts | 2 +- .../src/core/entities/UserEntityService.ts | 2 +- .../src/server/api/endpoints/i/update.ts | 27 ++++++------- packages/frontend/src/pages/about.vue | 2 +- .../frontend/src/pages/admin/roles.editor.vue | 38 +++++++++---------- .../frontend/src/pages/settings/profile.vue | 10 +++-- packages/frontend/src/pages/user/home.vue | 14 ++++++- 11 files changed, 61 insertions(+), 43 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 02942000e..0e8d053bf 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2273,6 +2273,7 @@ _profile: sectionName: "Section name" sectionNameNoneDescription: "Do not display the section name" sectionNameNone: "Section without name" + policyDisplayLimitExceeded: "The number of items displayed exceeds the current support plan's limit ({max}). This item will not be displayed. You can upgrade your plan [here](https://go.misskey.io/donate)." _exportOrImport: allNotes: "All notes" favoritedNotes: "Favorite notes" diff --git a/locales/index.d.ts b/locales/index.d.ts index 49ebe9bc6..1efcd8d71 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -8862,6 +8862,10 @@ export interface Locale extends ILocale { * 名前が表示されないセクション */ "sectionNameNone": string; + /** + * 現在の支援プランの表示上限({max}個)を超えているため、この項目は表示されません。[ここ](https://go.misskey.io/donate)からプランをアップグレードできます。 + */ + "policyDisplayLimitExceeded": ParameterizedString<"max">; }; "_exportOrImport": { /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b2d9ae81a..727d687a3 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2329,6 +2329,7 @@ _profile: sectionName: "セクション名" sectionNameNoneDescription: "セクション名を表示しないようにする" sectionNameNone: "名前が表示されないセクション" + policyDisplayLimitExceeded: "現在の支援プランの表示上限({max}個)を超えているため、この項目は表示されません。[ここ](https://go.misskey.io/donate)からプランをアップグレードできます。" _exportOrImport: allNotes: "全てのノート" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 50b758959..0f9111b2d 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -2255,8 +2255,9 @@ _profile: addMutualLink: "서로링크 추가" addMutualLinkSection: "섹션 추가" sectionName: "섹션 이름" - sectionNameNoneDescription: "섹션 이름이 표시되지 않도록 합니다." + sectionNameNoneDescription: "섹션 이름이 표시되지 않도록 합니다" sectionNameNone: "이름이 표시되지 않는 섹션" + policyDisplayLimitExceeded: "현재 지원 플랜의 표시 제한({max}개)을 초과하였기 때문에 이 항목은 표시되지 않습니다. [여기](https://go.misskey.io/donate)에서 플랜을 업그레이드할 수 있습니다." _exportOrImport: allNotes: "모든 노트" favoritedNotes: "즐겨찾기한 노트" diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index 111eb5c6f..45e8b641c 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -111,7 +111,7 @@ export const DEFAULT_POLICIES: RolePolicies = { rateLimitFactor: 1, avatarDecorationLimit: 1, mutualLinkSectionLimit: 1, - mutualLinkLimit: 15, + mutualLinkLimit: 3, }; @Injectable() diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 2091110e2..66ae69ed9 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -533,7 +533,7 @@ export class UserEntityService implements OnModuleInit { lang: profile!.lang, fields: profile!.fields, verifiedLinks: profile!.verifiedLinks, - mutualLinkSections: profile!.mutualLinkSections, + mutualLinkSections: isMe ? profile!.mutualLinkSections : profile!.mutualLinkSections.slice(0, policies!.mutualLinkSectionLimit).map(section => ({ ...section, mutualLinks: section.mutualLinks.slice(0, policies!.mutualLinkLimit) })), followersCount: followersCount ?? 0, followingCount: followingCount ?? 0, notesCount: user.notesCount, diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 96395f0a5..c055ff3e3 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -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 { // 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(), diff --git a/packages/frontend/src/pages/about.vue b/packages/frontend/src/pages/about.vue index 1ce551aa5..3bacfb3f3 100644 --- a/packages/frontend/src/pages/about.vue +++ b/packages/frontend/src/pages/about.vue @@ -99,7 +99,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.support }} - + {{ i18n.tsx.supportThisInstance({ name: instance.name ?? host }) }} diff --git a/packages/frontend/src/pages/admin/roles.editor.vue b/packages/frontend/src/pages/admin/roles.editor.vue index 325421158..2665bfb90 100644 --- a/packages/frontend/src/pages/admin/roles.editor.vue +++ b/packages/frontend/src/pages/admin/roles.editor.vue @@ -755,25 +755,6 @@ SPDX-License-Identifier: AGPL-3.0-only - - - -
- - - - - - - - -
-
-