diff --git a/locales/en-US.yml b/locales/en-US.yml index 90ce449e74..427cd8a2a6 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1229,6 +1229,7 @@ refreshing: "Refreshing..." pullDownToRefresh: "Pull down to refresh" disableStreamingTimeline: "Disable real-time timeline updates" useGroupedNotifications: "Display grouped notifications" +allowClickingNotifications: "Allow clicking on pop-up notifications" signupPendingError: "There was a problem verifying the email address. The link may have expired." cwNotationRequired: "If \"Hide content\" is enabled, a description must be provided." doReaction: "Add reaction" diff --git a/locales/index.d.ts b/locales/index.d.ts index f27793b860..89a929d054 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -4943,6 +4943,10 @@ export interface Locale extends ILocale { * 通知をグルーピングして表示する */ "useGroupedNotifications": string; + /** + * ポップアップ通知のクリックを許可する + */ + "allowClickingNotifications": string; /** * メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。 */ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 4d22aa87d1..04ff7982ad 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1231,6 +1231,7 @@ refreshing: "リロード中" pullDownToRefresh: "引っ張ってリロード" disableStreamingTimeline: "タイムラインのリアルタイム更新を無効にする" useGroupedNotifications: "通知をグルーピングして表示する" +allowClickingNotifications: "ポップアップ通知のクリックを許可する" signupPendingError: "メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。" cwNotationRequired: "「内容を隠す」がオンの場合は注釈の記述が必要です。" doReaction: "リアクションする" diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 6d70f35883..2ff07b2679 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -79,6 +79,7 @@ import * as ep___admin_silenceUser from './endpoints/admin/silence-user.js'; import * as ep___admin_unsilenceUser from './endpoints/admin/unsilence-user.js'; import * as ep___admin_suspendUser from './endpoints/admin/suspend-user.js'; import * as ep___admin_approveUser from './endpoints/admin/approve-user.js'; +import * as ep___admin_declineUser from './endpoints/admin/decline-user.js'; import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js'; import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js'; import * as ep___admin_deleteAccount from './endpoints/admin/delete-account.js'; @@ -479,6 +480,7 @@ const $admin_silenceUser: Provider = { provide: 'ep:admin/silence-user', useClas const $admin_unsilenceUser: Provider = { provide: 'ep:admin/unsilence-user', useClass: ep___admin_unsilenceUser.default }; const $admin_suspendUser: Provider = { provide: 'ep:admin/suspend-user', useClass: ep___admin_suspendUser.default }; const $admin_approveUser: Provider = { provide: 'ep:admin/approve-user', useClass: ep___admin_approveUser.default }; +const $admin_declineUser: Provider = { provide: 'ep:admin/decline-user', useClass: ep___admin_declineUser.default }; const $admin_unsuspendUser: Provider = { provide: 'ep:admin/unsuspend-user', useClass: ep___admin_unsuspendUser.default }; const $admin_updateMeta: Provider = { provide: 'ep:admin/update-meta', useClass: ep___admin_updateMeta.default }; const $admin_deleteAccount: Provider = { provide: 'ep:admin/delete-account', useClass: ep___admin_deleteAccount.default }; @@ -883,6 +885,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__ $admin_unsilenceUser, $admin_suspendUser, $admin_approveUser, + $admin_declineUser, $admin_unsuspendUser, $admin_updateMeta, $admin_deleteAccount, @@ -1281,6 +1284,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__ $admin_unsilenceUser, $admin_suspendUser, $admin_approveUser, + $admin_declineUser, $admin_unsuspendUser, $admin_updateMeta, $admin_deleteAccount, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 75a72eb063..3c46843992 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -85,6 +85,7 @@ import * as ep___admin_silenceUser from './endpoints/admin/silence-user.js'; import * as ep___admin_unsilenceUser from './endpoints/admin/unsilence-user.js'; import * as ep___admin_suspendUser from './endpoints/admin/suspend-user.js'; import * as ep___admin_approveUser from './endpoints/admin/approve-user.js'; +import * as ep___admin_declineUser from './endpoints/admin/decline-user.js'; import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js'; import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js'; import * as ep___admin_deleteAccount from './endpoints/admin/delete-account.js'; @@ -483,6 +484,7 @@ const eps = [ ['admin/unsilence-user', ep___admin_unsilenceUser], ['admin/suspend-user', ep___admin_suspendUser], ['admin/approve-user', ep___admin_approveUser], + ['admin/decline-user', ep___admin_declineUser], ['admin/unsuspend-user', ep___admin_unsuspendUser], ['admin/update-meta', ep___admin_updateMeta], ['admin/delete-account', ep___admin_deleteAccount], diff --git a/packages/backend/src/server/api/endpoints/admin/decline-user.ts b/packages/backend/src/server/api/endpoints/admin/decline-user.ts new file mode 100644 index 0000000000..0a75dd977d --- /dev/null +++ b/packages/backend/src/server/api/endpoints/admin/decline-user.ts @@ -0,0 +1,75 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import type { UsedUsernamesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js'; +import { ModerationLogService } from '@/core/ModerationLogService.js'; +import { DI } from '@/di-symbols.js'; +import { EmailService } from '@/core/EmailService.js'; +import { DeleteAccountService } from '@/core/DeleteAccountService.js'; + +export const meta = { + tags: ['admin'], + + requireCredential: true, + requireModerator: true, + kind: 'write:admin:decline-user', +} as const; + +export const paramDef = { + type: 'object', + properties: { + userId: { type: 'string', format: 'misskey:id' }, + }, + required: ['userId'], +} as const; + +@Injectable() +export default class extends Endpoint { // eslint-disable-line import/no-default-export + constructor( + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + + @Inject(DI.userProfilesRepository) + private userProfilesRepository: UserProfilesRepository, + + @Inject(DI.usedUsernamesRepository) + private usedUsernamesRepository: UsedUsernamesRepository, + + private moderationLogService: ModerationLogService, + private emailService: EmailService, + private deleteAccountService: DeleteAccountService, + ) { + super(meta, paramDef, async (ps, me) => { + const user = await this.usersRepository.findOneBy({ id: ps.userId }); + + if (user == null || user.isDeleted) { + throw new Error('user not found or already deleted'); + } + + if (user.approved) { + throw new Error('user is already approved'); + } + + if (user.host) { + throw new Error('user is not local'); + } + + const profile = await this.userProfilesRepository.findOneBy({ userId: ps.userId }); + + if (profile?.email) { + this.emailService.sendEmail(profile.email, 'Account Declined', + 'Your Account has been declined!', + 'Your Account has been declined!'); + } + + await this.usedUsernamesRepository.delete({ username: user.username }); + + await this.deleteAccountService.deleteAccount(user); + + this.moderationLogService.log(me, 'decline', { + userId: user.id, + userUsername: user.username, + userHost: user.host, + }); + }); + } +} diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index d2ddbafdb3..2aa4f279ea 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -72,6 +72,7 @@ export const moderationLogTypes = [ 'updateServerSettings', 'suspend', 'approve', + 'decline', 'unsuspend', 'updateUserNote', 'addCustomEmoji', @@ -139,6 +140,11 @@ export type ModerationLogPayloads = { userUsername: string; userHost: string | null; }; + decline: { + userId: string; + userUsername: string; + userHost: string | null; + }; unsuspend: { userId: string; userUsername: string; diff --git a/packages/frontend/src/components/SkApprovalUser.vue b/packages/frontend/src/components/SkApprovalUser.vue index 20059f139d..1ef0ac5b17 100644 --- a/packages/frontend/src/components/SkApprovalUser.vue +++ b/packages/frontend/src/components/SkApprovalUser.vue @@ -69,22 +69,10 @@ async function deleteAccount() { }); if (confirm.canceled) return; - const typed = await os.inputText({ - text: i18n.t('typeToConfirm', { x: props.user.username }), + await os.apiWithDialog('admin/decline-user', { + userId: props.user.id, }); - if (typed.canceled) return; - - if (typed.result === props.user.username) { - await os.apiWithDialog('admin/delete-account', { - userId: props.user.id, - }); - emits('deleted', props.user.id); - } else { - os.alert({ - type: 'error', - text: 'input not match', - }); - } + emits('deleted', props.user.id); } async function approveAccount() { diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue index 9fe804b2bd..6c81155c51 100644 --- a/packages/frontend/src/pages/admin/modlog.ModLog.vue +++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue @@ -31,6 +31,7 @@ SPDX-License-Identifier: AGPL-3.0-only [$style.logRed]: [ 'suspend', 'approve', + 'decline', 'deleteRole', 'deleteGlobalAnnouncement', 'deleteUserAnnouncement', @@ -51,6 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} + : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} : @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }} {{ log.info.roleName }} diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 27607322ee..e1068132b7 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -170,6 +170,8 @@ SPDX-License-Identifier: AGPL-3.0-only + {{ i18n.ts.allowClickingNotifications }} + {{ i18n.ts._notification.checkNotificationBehavior }} @@ -414,6 +416,7 @@ const showAvatarDecorations = computed(defaultStore.makeGetterSetter('showAvatar const mediaListWithOneImageAppearance = computed(defaultStore.makeGetterSetter('mediaListWithOneImageAppearance')); const notificationPosition = computed(defaultStore.makeGetterSetter('notificationPosition')); const notificationStackAxis = computed(defaultStore.makeGetterSetter('notificationStackAxis')); +const notificationClickable = computed(defaultStore.makeGetterSetter('notificationClickable')); const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn')); const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disableStreamingTimeline')); const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications')); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index a00afcd79a..8f356c557b 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -481,6 +481,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: 'horizontal' as 'vertical' | 'horizontal', }, + notificationClickable: { + where: 'device', + default: false, + }, enableCondensedLine: { where: 'device', default: true, diff --git a/packages/frontend/src/ui/_common_/common.vue b/packages/frontend/src/ui/_common_/common.vue index e9baa0eab4..a8ff2a4c8d 100644 --- a/packages/frontend/src/ui/_common_/common.vue +++ b/packages/frontend/src/ui/_common_/common.vue @@ -30,7 +30,11 @@ SPDX-License-Identifier: AGPL-3.0-only :enterFromClass="defaultStore.state.animation ? $style.transition_notification_enterFrom : ''" :leaveToClass="defaultStore.state.animation ? $style.transition_notification_leaveTo : ''" > -
+
@@ -101,6 +105,10 @@ if ($i) { swInject(); } } + +function getPointerEvents() { + return defaultStore.state.notificationClickable ? undefined : 'none'; +}