Add note auto delete feature #1

Merged
heartles merged 5 commits from wip-self-destruct into main 2024-03-18 04:46:58 +00:00
6 changed files with 49 additions and 0 deletions
Showing only changes of commit 83c971b1a8 - Show all commits

View file

@ -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";`);
}
}

View file

@ -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,

View file

@ -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', {

View file

@ -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,

View file

@ -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<typeof meta, typeof paramDef> { // eslint-
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
mutedWords: profile.mutedWords,
mutedInstances: profile.mutedInstances,
autoDeleteNotesMinutes: profile.autoDeleteNotesMinutes,
autoDeleteNotes: profile.autoDeleteNotes,
notificationRecieveConfig: profile.notificationRecieveConfig,
isModerator: isModerator,
isSilenced: isSilenced,

View file

@ -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<typeof meta, typeof paramDef> { // 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;