diff --git a/packages/backend/migration/1729414690009-defaultSensitive.js b/packages/backend/migration/1729414690009-defaultSensitive.js new file mode 100644 index 0000000000..47debf05a7 --- /dev/null +++ b/packages/backend/migration/1729414690009-defaultSensitive.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: marie and sharkey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class DefaultSensitive1729414690009 { + name = 'DefaultSensitive1729414690009' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "user_profile" ADD "defaultSensitive" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "defaultSensitive"`); + } +} diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index 744bc65be7..520c339d7d 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -560,7 +560,7 @@ export class DriveService { file.maybeSensitive = info.sensitive; file.maybePorn = info.porn; file.isSensitive = user - ? this.userEntityService.isLocalUser(user) && profile!.alwaysMarkNsfw ? true : + ? this.userEntityService.isLocalUser(user) && (profile!.alwaysMarkNsfw || profile!.defaultSensitive) ? true : sensitive ?? false : false; diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 703b07973e..b1832ca0f5 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -627,6 +627,7 @@ export class UserEntityService implements OnModuleInit { injectFeaturedNote: profile!.injectFeaturedNote, receiveAnnouncementEmail: profile!.receiveAnnouncementEmail, alwaysMarkNsfw: profile!.alwaysMarkNsfw, + defaultSensitive: profile!.defaultSensitive, autoSensitive: profile!.autoSensitive, carefulBot: profile!.carefulBot, autoAcceptFollowed: profile!.autoAcceptFollowed, diff --git a/packages/backend/src/models/UserProfile.ts b/packages/backend/src/models/UserProfile.ts index 9b87130ce1..751b1aff08 100644 --- a/packages/backend/src/models/UserProfile.ts +++ b/packages/backend/src/models/UserProfile.ts @@ -196,6 +196,11 @@ export class MiUserProfile { }) public alwaysMarkNsfw: boolean; + @Column('boolean', { + default: false, + }) + public defaultSensitive: boolean; + @Column('boolean', { default: false, }) diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index beb4dcc12c..fdbd5fa8e2 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -516,6 +516,10 @@ export const packedMeDetailedOnlySchema = { type: 'boolean', nullable: false, optional: false, }, + defaultSensitive: { + type: 'boolean', + nullable: false, optional: false, + }, autoSensitive: { type: 'boolean', nullable: false, optional: false, diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 026ad614d8..8994c3fff6 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -193,6 +193,7 @@ export const paramDef = { injectFeaturedNote: { type: 'boolean' }, receiveAnnouncementEmail: { type: 'boolean' }, alwaysMarkNsfw: { type: 'boolean' }, + defaultSensitive: { type: 'boolean' }, autoSensitive: { type: 'boolean' }, followingVisibility: { type: 'string', enum: ['public', 'followers', 'private'] }, followersVisibility: { type: 'string', enum: ['public', 'followers', 'private'] }, @@ -349,6 +350,7 @@ export default class extends Endpoint { // eslint- if (policies.alwaysMarkNsfw) throw new ApiError(meta.errors.restrictedByRole); profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw; } + if (typeof ps.defaultSensitive === 'boolean') profileUpdates.defaultSensitive = ps.defaultSensitive; if (ps.emailNotificationTypes !== undefined) profileUpdates.emailNotificationTypes = ps.emailNotificationTypes; if (ps.avatarId) { diff --git a/packages/frontend/src/pages/settings/drive.vue b/packages/frontend/src/pages/settings/drive.vue index fa09637844..c1e3258631 100644 --- a/packages/frontend/src/pages/settings/drive.vue +++ b/packages/frontend/src/pages/settings/drive.vue @@ -48,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -80,7 +80,7 @@ const fetching = ref(true); const usage = ref(null); const capacity = ref(null); const uploadFolder = ref(null); -const alwaysMarkNsfw = ref($i.alwaysMarkNsfw); +const defaultSensitive = ref($i.defaultSensitive); const meterStyle = computed(() => { if (!capacity.value || !usage.value) return {}; @@ -127,14 +127,14 @@ function chooseUploadFolder() { function saveProfile() { misskeyApi('i/update', { - alwaysMarkNsfw: !!alwaysMarkNsfw.value, + defaultSensitive: !!defaultSensitive.value, }).catch(err => { os.alert({ type: 'error', title: i18n.ts.error, text: err.message, }); - alwaysMarkNsfw.value = true; + defaultSensitive.value = true; }); } diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index c02295d444..941c31455f 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -3994,6 +3994,7 @@ export type components = { injectFeaturedNote: boolean; receiveAnnouncementEmail: boolean; alwaysMarkNsfw: boolean; + defaultSensitive: boolean; autoSensitive: boolean; carefulBot: boolean; autoAcceptFollowed: boolean; @@ -20545,6 +20546,7 @@ export type operations = { injectFeaturedNote?: boolean; receiveAnnouncementEmail?: boolean; alwaysMarkNsfw?: boolean; + defaultSensitive?: boolean; autoSensitive?: boolean; /** @enum {string} */ followingVisibility?: 'public' | 'followers' | 'private';