diff --git a/packages/backend/migration/1709530777533-autoDeleteNotes.js b/packages/backend/migration/1709530777533-autoDeleteNotes.js new file mode 100644 index 0000000000..2b296c4f29 --- /dev/null +++ b/packages/backend/migration/1709530777533-autoDeleteNotes.js @@ -0,0 +1,14 @@ +export class AutoDeleteNotes1709530777533 { + name = "AutoDeleteNotes1709530777533"; + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE user_profile ADD "autoDeleteNotes" boolean NOT NULL DEFAULT false;`); + await queryRunner.query(`ALTER TABLE user_profile ADD "autoDeleteNotesMinutes" integer NOT NULL DEFAULT 43200;`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE user_profile DROP COLUMN "autoDeleteNotes";`); + await queryRunner.query(`ALTER TABLE user_profile DROP COLUMN "autoDeleteNotesMinutes";`); + } + +} diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 8f5d986fac..20a3ca64c7 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -509,6 +509,8 @@ export class UserEntityService implements OnModuleInit { mutedWords: profile!.mutedWords, hardMutedWords: profile!.hardMutedWords, mutedInstances: profile!.mutedInstances, + autoDeleteNotes: profile!.autoDeleteNotes, + autoDeleteNotesMinutes: profile!.autoDeleteNotesMinutes, mutingNotificationTypes: [], // 後方互換性のため notificationRecieveConfig: profile!.notificationRecieveConfig, emailNotificationTypes: profile!.emailNotificationTypes, diff --git a/packages/backend/src/models/UserProfile.ts b/packages/backend/src/models/UserProfile.ts index 40ea26f610..f0e06866a4 100644 --- a/packages/backend/src/models/UserProfile.ts +++ b/packages/backend/src/models/UserProfile.ts @@ -277,6 +277,17 @@ export class MiUserProfile { unlockedAt: number; }[]; + @Column('boolean', { + default: false, + }) + public autoDeleteNotes: boolean; + + @Column('integer', { + default: 43200, // 30 days in minutes + }) + public autoDeleteNotesMinutes: number; + + //#region Denormalized fields @Index() @Column('varchar', { diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index 33a3efd453..c31291a6a4 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -605,6 +605,14 @@ export const packedMeDetailedOnlySchema = { nullable: false, optional: false, }, }, + autoDeleteNotes: { + type: 'boolean', + nullable: false, optional: false, + }, + autoDeleteNotesMinutes: { + type: 'number', + nullable: false, optional: false, + }, notificationRecieveConfig: { type: 'object', nullable: false, optional: false, diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index 9cdca02224..818322eb8e 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -88,6 +88,14 @@ export const meta = { type: 'string', }, }, + autoDeleteNotes: { + type: 'boolean', + optional: false, nullable: false, + }, + autoDeleteNotesMinutes: { + type: 'number', + optional: false, nullable: false, + }, notificationRecieveConfig: { type: 'object', optional: false, nullable: false, @@ -239,6 +247,8 @@ export default class extends Endpoint { // eslint- receiveAnnouncementEmail: profile.receiveAnnouncementEmail, mutedWords: profile.mutedWords, mutedInstances: profile.mutedInstances, + autoDeleteNotesMinutes: profile.autoDeleteNotesMinutes, + autoDeleteNotes: profile.autoDeleteNotes, notificationRecieveConfig: profile.notificationRecieveConfig, isModerator: isModerator, isSilenced: isSilenced, diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index cb413de9ee..7bd3cbf68d 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -202,6 +202,8 @@ export const paramDef = { mutedInstances: { type: 'array', items: { type: 'string', } }, + autoDeleteNotes: { type: 'boolean', nullable: false }, + autoDeleteNotesMinutes: { type: 'number', nullable: false, minimum: 1 }, notificationRecieveConfig: { type: 'object', nullable: false, @@ -319,6 +321,8 @@ export default class extends Endpoint { // eslint- profileUpdates.hardMutedWords = ps.hardMutedWords; } if (ps.mutedInstances !== undefined) profileUpdates.mutedInstances = ps.mutedInstances; + if (ps.autoDeleteNotes !== undefined) profileUpdates.autoDeleteNotes = ps.autoDeleteNotes; + if (ps.autoDeleteNotesMinutes !== undefined) profileUpdates.autoDeleteNotesMinutes = ps.autoDeleteNotesMinutes; if (ps.notificationRecieveConfig !== undefined) profileUpdates.notificationRecieveConfig = ps.notificationRecieveConfig; if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked; if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;