Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 絵文字削除ロールの追加 #130

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,7 @@ _role:
canUseChannel: "チャンネルの利用"
canUseHighlight: "ハイライトの利用"
canUseRemoteIconDecorations: "リモートアイコンデコレーションの利用"
canEmojiDeletion: "絵文字の削除"
driveCapacity: "ドライブ容量"
alwaysMarkNsfw: "ファイルにNSFWを常に付与"
pinMax: "ノートのピン留めの最大数"
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type RolePolicies = {
canUseChannel: boolean;
canUseHighlight: boolean;
canUseRemoteIconDecorations: boolean;
canEmojiDeletion: boolean;
canSearchNotes: boolean;
canUseTranslator: boolean;
canHideAds: boolean;
Expand Down Expand Up @@ -78,6 +79,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
canManageAvatarDecorations: false,
canUseChannel: false,
canUseRemoteIconDecorations: true,
canEmojiDeletion: false,
canUseHighlight: true,
canSearchNotes: false,
canUseTranslator: true,
Expand Down Expand Up @@ -385,6 +387,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
canUseChannel: calc('canUseChannel', vs => vs.some(v => v === true)),
canUseHighlight: calc('canUseHighlight', vs => vs.some(v => v === true)),
canUseRemoteIconDecorations: calc('canUseRemoteIconDecorations', vs => vs.some(v => v === true)),
canEmojiDeletion: calc('canEmojiDeletion', vs => vs.some(v => v === true)),
canSearchNotes: calc('canSearchNotes', vs => vs.some(v => v === true)),
canUseTranslator: calc('canUseTranslator', vs => vs.some(v => v === true)),
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export const packedRolePoliciesSchema = {
type: 'boolean',
optional: false, nullable: false,
},
canEmojiDeletion: {
type: 'boolean',
optional: false, nullable: false,
},
canSearchNotes: {
type: 'boolean',
optional: false, nullable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],

requireCredential: true,
requireRolePolicy: 'canManageCustomEmojis',
requireRolePolicy: 'canEmojiDeletion',
kind: 'write:admin:emoji',
} as const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],

requireCredential: true,
requireRolePolicy: 'canManageCustomEmojis',
requireRolePolicy: 'canEmojiDeletion',
kind: 'write:admin:emoji',

errors: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const meta = {
tags: ['admin'],

requireCredential: true,
requireRolePolicy: 'canManageCustomEmojis',
requireRolePolicy: 'canEmojiDeletion',
kind: 'write:admin:emoji',
} as const;

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const ROLE_POLICIES = [
'canUseChannel',
'canUseHighlight',
'canUseRemoteIconDecorations',
'canEmojiDeletion',
'canSearchNotes',
'canUseTranslator',
'canHideAds',
Expand Down
22 changes: 21 additions & 1 deletion packages/frontend/src/pages/admin/roles.editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkRange>
</div>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.canScheduleNote, 'canScheduleNote'])">
<template #label>{{ i18n.ts._role._options.canScheduleNote }}</template>
<template #suffix>
Expand Down Expand Up @@ -378,6 +378,26 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.canEmojiDeletion, 'canEmojiDeletion'])">
<template #label>{{ i18n.ts._role._options.canEmojiDeletion }}</template>
<template #suffix>
<span v-if="role.policies.canEmojiDeletion.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
<span v-else>{{ role.policies.canEmojiDeletion.value ? i18n.ts.yes : i18n.ts.no }}</span>
<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.canUseHighlight)"></i></span>
</template>
<div class="_gaps">
<MkSwitch v-model="role.policies.canEmojiDeletion.useDefault" :readonly="readonly">
<template #label>{{ i18n.ts._role.useBaseValue }}</template>
</MkSwitch>
<MkSwitch v-model="role.policies.canEmojiDeletion.value" :disabled="role.policies.canEmojiDeletion.useDefault" :readonly="readonly">
<template #label>{{ i18n.ts.enable }}</template>
</MkSwitch>
<MkRange v-model="role.policies.canEmojiDeletion.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
<template #label>{{ i18n.ts._role.priority }}</template>
</MkRange>
</div>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.remoteLocalTimelineAnyLimit, 'remoteLocalTimelineAnyLimit'])">
<template #label>{{ i18n.ts._role._options.remoteLocalTimelineAnyLimit }}</template>
<template #suffix>
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend/src/pages/admin/roles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="policies.mentionLimit" type="number">
</MkInput>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.canScheduleNote, 'canScheduleNote'])">
<template #label>{{ i18n.ts._role._options.canScheduleNote }}</template>
<template #suffix>{{ policies.canScheduleNote ? i18n.ts.yes : i18n.ts.no }}</template>
Expand Down Expand Up @@ -133,6 +133,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkSwitch>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.canEmojiDeletion, 'canEmojiDeletion'])">
<template #label>{{ i18n.ts._role._options.canEmojiDeletion }}</template>
<template #suffix>{{ policies.canEmojiDeletion ? i18n.ts.yes : i18n.ts.no }}</template>
<MkSwitch v-model="policies.canEmojiDeletion">
<template #label>{{ i18n.ts.enable }}</template>
</MkSwitch>
</MkFolder>

<MkFolder v-if="matchQuery([i18n.ts._role._options.canManageCustomEmojis, 'canManageCustomEmojis'])">
<template #label>{{ i18n.ts._role._options.canManageCustomEmojis }}</template>
<template #suffix>{{ policies.canManageCustomEmojis ? i18n.ts.yes : i18n.ts.no }}</template>
Expand Down
1 change: 1 addition & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4723,6 +4723,7 @@ export type components = {
canUseChannel: boolean;
canUseHighlight: boolean;
canUseRemoteIconDecorations: boolean;
canEmojiDeletion: boolean;
canSearchNotes: boolean;
canUseTranslator: boolean;
canHideAds: boolean;
Expand Down
Loading