Skip to content

Commit

Permalink
Role timeline setting (misskey-dev#10677)
Browse files Browse the repository at this point in the history
* ロールタイムライン設定

* isRoleTimeline to isExplorable

* ポリシーではないので削除

* 型からも

* wip

* 足りてなかった説

* wip

* listはpublicを表示

* 前回の記載修正( misskey-dev#10671 )

---------

Co-authored-by: syuilo <[email protected]>
  • Loading branch information
2 people authored and sasagar committed May 9, 2023
1 parent f19ed03 commit 217fab8
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
### Client
-
- カスタム絵文字のライセンスを複数でセットできるようになりました。
### Server
-
Expand All @@ -27,6 +26,9 @@
(自分自身に対してもメモを追加できます。)
- ユーザーメニューから追加できます。
(デスクトップ表示では username の右側のボタンからも追加可能)
- ロールタイムラインをロールごとに表示するかどうかの選択できるようになりました。
- デフォルトがオフになるので、ロールタイムラインを表示する場合はオンにしてください。
- カスタム絵文字のライセンスを複数でセットできるようになりました。

### Client

Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,8 @@ _role:
iconUrl: "アイコン画像のURL"
asBadge: "バッジとして表示"
descriptionOfAsBadge: "オンにすると、ユーザー名の横にロールのアイコンが表示されます。"
isExplorable: "ロールタイムラインを公開"
descriptionOfIsExplorable: "オンにすると、ロールのタイムラインを公開します。ロールの公開がオフの場合、タイムラインの公開はされません。"
displayOrder: "表示順"
descriptionOfDisplayOrder: "数値が大きいほどUI上で先頭に表示されます。"
canEditMembersByModerator: "モデレーターのメンバー編集を許可"
Expand Down
12 changes: 12 additions & 0 deletions packages/backend/migration/1681870960239-RoleTLSetting.js
Original file line number Diff line number Diff line change
@@ -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"`);
}

}
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/RoleEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/entities/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export class Role {
})
public isAdministrator: boolean;

@Column('boolean', {
default: false,
})
public isExplorable: boolean;

@Column('boolean', {
default: false,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -42,6 +43,7 @@ export const paramDef = {
'isPublic',
'isModerator',
'isAdministrator',
'isExplorable',
'asBadge',
'canEditMembersByModerator',
'displayOrder',
Expand Down Expand Up @@ -76,6 +78,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
isPublic: ps.isPublic,
isAdministrator: ps.isAdministrator,
isModerator: ps.isModerator,
isExplorable: ps.isExplorable,
asBadge: ps.asBadge,
canEditMembersByModerator: ps.canEditMembersByModerator,
displayOrder: ps.displayOrder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -85,6 +86,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
isPublic: ps.isPublic,
isModerator: ps.isModerator,
isAdministrator: ps.isAdministrator,
isExplorable: ps.isExplorable,
asBadge: ps.asBadge,
canEditMembersByModerator: ps.canEditMembersByModerator,
displayOrder: ps.displayOrder,
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/server/api/endpoints/roles/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
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}`,
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/pages/admin/roles.edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if (props.id) {
target: 'manual',
condFormula: { id: uuid(), type: 'isRemote' },
isPublic: false,
isExplorable: false,
asBadge: false,
canEditMembersByModerator: false,
displayOrder: 0,
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/pages/admin/roles.editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<template #caption>{{ i18n.ts._role.descriptionOfAsBadge }}</template>
</MkSwitch>

<MkSwitch v-model="role.isExplorable" :readonly="readonly">
<template #label>{{ i18n.ts._role.isExplorable }}</template>
<template #caption>{{ i18n.ts._role.descriptionOfIsExplorable }}</template>
</MkSwitch>

<FormSlot>
<template #label><i class="ti ti-license"></i> {{ i18n.ts._role.policies }}</template>
<div class="_gaps_s">
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 217fab8

Please sign in to comment.