From 8dc60cd3273be7103050bb8e680db03f2856cec3 Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 20 Apr 2023 20:02:50 +0900 Subject: [PATCH] Role timeline setting (#10677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ロールタイムライン設定 * isRoleTimeline to isExplorable * ポリシーではないので削除 * 型からも * wip * 足りてなかった説 * wip * listはpublicを表示 * 前回の記載修正( #10671 ) --------- Co-authored-by: syuilo --- CHANGELOG.md | 4 +++- locales/ja-JP.yml | 2 ++ .../backend/migration/1681870960239-RoleTLSetting.js | 12 ++++++++++++ .../backend/src/core/entities/RoleEntityService.ts | 1 + packages/backend/src/models/entities/Role.ts | 5 +++++ .../src/server/api/endpoints/admin/roles/create.ts | 3 +++ .../src/server/api/endpoints/admin/roles/update.ts | 2 ++ .../backend/src/server/api/endpoints/roles/notes.ts | 5 ++++- packages/frontend/src/pages/admin/roles.edit.vue | 1 + packages/frontend/src/pages/admin/roles.editor.vue | 6 ++++++ 10 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 packages/backend/migration/1681870960239-RoleTLSetting.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a6fd30952..97ce4ec7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ ### Client - -- カスタム絵文字のライセンスを複数でセットできるようになりました。 ### Server - @@ -24,6 +23,9 @@ (自分自身に対してもメモを追加できます。) * ユーザーメニューから追加できます。 (デスクトップ表示ではusernameの右側のボタンからも追加可能) +- ロールタイムラインをロールごとに表示するかどうかの選択できるようになりました。 + * デフォルトがオフになるので、ロールタイムラインを表示する場合はオンにしてください。 +- カスタム絵文字のライセンスを複数でセットできるようになりました。 ### Client - 通知の表示をカスタマイズできるように diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6f6f49ab2..69fca92f6 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1291,6 +1291,8 @@ _role: iconUrl: "アイコン画像のURL" asBadge: "バッジとして表示" descriptionOfAsBadge: "オンにすると、ユーザー名の横にロールのアイコンが表示されます。" + isExplorable: "ロールタイムラインを公開" + descriptionOfIsExplorable: "オンにすると、ロールのタイムラインを公開します。ロールの公開がオフの場合、タイムラインの公開はされません。" displayOrder: "表示順" descriptionOfDisplayOrder: "数値が大きいほどUI上で先頭に表示されます。" canEditMembersByModerator: "モデレーターのメンバー編集を許可" diff --git a/packages/backend/migration/1681870960239-RoleTLSetting.js b/packages/backend/migration/1681870960239-RoleTLSetting.js new file mode 100644 index 000000000..2280f44ea --- /dev/null +++ b/packages/backend/migration/1681870960239-RoleTLSetting.js @@ -0,0 +1,12 @@ +export class RoleTLSetting1681870960239 { + name = 'RoleTLSetting1681870960239' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "role" ADD "isExplorable" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "role" DROP COLUMN "isExplorable"`); + } + +} diff --git a/packages/backend/src/core/entities/RoleEntityService.ts b/packages/backend/src/core/entities/RoleEntityService.ts index e111a10b7..54818782d 100644 --- a/packages/backend/src/core/entities/RoleEntityService.ts +++ b/packages/backend/src/core/entities/RoleEntityService.ts @@ -59,6 +59,7 @@ export class RoleEntityService { isPublic: role.isPublic, isAdministrator: role.isAdministrator, isModerator: role.isModerator, + isExplorable: role.isExplorable, asBadge: role.asBadge, canEditMembersByModerator: role.canEditMembersByModerator, displayOrder: role.displayOrder, diff --git a/packages/backend/src/models/entities/Role.ts b/packages/backend/src/models/entities/Role.ts index eca9bcf27..61f40d59d 100644 --- a/packages/backend/src/models/entities/Role.ts +++ b/packages/backend/src/models/entities/Role.ts @@ -151,6 +151,11 @@ export class Role { }) public isAdministrator: boolean; + @Column('boolean', { + default: false, + }) + public isExplorable: boolean; + @Column('boolean', { default: false, }) diff --git a/packages/backend/src/server/api/endpoints/admin/roles/create.ts b/packages/backend/src/server/api/endpoints/admin/roles/create.ts index 135989463..5440c4563 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/create.ts @@ -25,6 +25,7 @@ export const paramDef = { isPublic: { type: 'boolean' }, isModerator: { type: 'boolean' }, isAdministrator: { type: 'boolean' }, + isExplorable: { type: 'boolean' }, asBadge: { type: 'boolean' }, canEditMembersByModerator: { type: 'boolean' }, displayOrder: { type: 'number' }, @@ -42,6 +43,7 @@ export const paramDef = { 'isPublic', 'isModerator', 'isAdministrator', + 'isExplorable', 'asBadge', 'canEditMembersByModerator', 'displayOrder', @@ -76,6 +78,7 @@ export default class extends Endpoint { isPublic: ps.isPublic, isAdministrator: ps.isAdministrator, isModerator: ps.isModerator, + isExplorable: ps.isExplorable, asBadge: ps.asBadge, canEditMembersByModerator: ps.canEditMembersByModerator, displayOrder: ps.displayOrder, diff --git a/packages/backend/src/server/api/endpoints/admin/roles/update.ts b/packages/backend/src/server/api/endpoints/admin/roles/update.ts index 37b68c4c4..467f157a6 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/update.ts @@ -33,6 +33,7 @@ export const paramDef = { isPublic: { type: 'boolean' }, isModerator: { type: 'boolean' }, isAdministrator: { type: 'boolean' }, + isExplorable: { type: 'boolean' }, asBadge: { type: 'boolean' }, canEditMembersByModerator: { type: 'boolean' }, displayOrder: { type: 'number' }, @@ -85,6 +86,7 @@ export default class extends Endpoint { isPublic: ps.isPublic, isModerator: ps.isModerator, isAdministrator: ps.isAdministrator, + isExplorable: ps.isExplorable, asBadge: ps.asBadge, canEditMembersByModerator: ps.canEditMembersByModerator, displayOrder: ps.displayOrder, diff --git a/packages/backend/src/server/api/endpoints/roles/notes.ts b/packages/backend/src/server/api/endpoints/roles/notes.ts index 90c8281a4..6202c740f 100644 --- a/packages/backend/src/server/api/endpoints/roles/notes.ts +++ b/packages/backend/src/server/api/endpoints/roles/notes.ts @@ -65,12 +65,15 @@ export default class extends Endpoint { super(meta, paramDef, async (ps, me) => { const role = await this.rolesRepository.findOneBy({ id: ps.roleId, + isPublic: true, }); if (role == null) { throw new ApiError(meta.errors.noSuchRole); } - + if (!role.isExplorable) { + return []; + } const limit = ps.limit + (ps.untilId ? 1 : 0) + (ps.sinceId ? 1 : 0); // untilIdに指定したものも含まれるため+1 const noteIdsRes = await this.redisClient.xrevrange( `roleTimeline:${role.id}`, diff --git a/packages/frontend/src/pages/admin/roles.edit.vue b/packages/frontend/src/pages/admin/roles.edit.vue index b1aa03f1f..c211ef2f0 100644 --- a/packages/frontend/src/pages/admin/roles.edit.vue +++ b/packages/frontend/src/pages/admin/roles.edit.vue @@ -54,6 +54,7 @@ if (props.id) { target: 'manual', condFormula: { id: uuid(), type: 'isRemote' }, isPublic: false, + isExplorable: false, asBadge: false, canEditMembersByModerator: false, displayOrder: 0, diff --git a/packages/frontend/src/pages/admin/roles.editor.vue b/packages/frontend/src/pages/admin/roles.editor.vue index 873ff02fe..649f64d12 100644 --- a/packages/frontend/src/pages/admin/roles.editor.vue +++ b/packages/frontend/src/pages/admin/roles.editor.vue @@ -59,6 +59,11 @@ + + + + +
@@ -475,6 +480,7 @@ const save = throttle(100, () => { isAdministrator: role.isAdministrator, isModerator: role.isModerator, isPublic: role.isPublic, + isExplorable: role.isExplorable, asBadge: role.asBadge, canEditMembersByModerator: role.canEditMembersByModerator, policies: role.policies,