Compare commits
3 commits
c03337dbf1
...
88ca0c14ef
Author | SHA1 | Date | |
---|---|---|---|
88ca0c14ef | |||
d2db36d0ee | |||
83c971b1a8 |
11 changed files with 109 additions and 69 deletions
|
@ -99,6 +99,7 @@ serverIsDead: "This server is not responding. Please wait for a while and try ag
|
|||
youShouldUpgradeClient: "To view this page, please refresh to update your client."
|
||||
enterListName: "Enter a name for the list"
|
||||
privacy: "Privacy"
|
||||
autoDeleteNotes: "Self-destructing notes"
|
||||
makeFollowManuallyApprove: "Follow requests require approval"
|
||||
defaultNoteVisibility: "Default visibility"
|
||||
follow: "Follow"
|
||||
|
@ -947,6 +948,7 @@ oneHour: "One hour"
|
|||
oneDay: "One day"
|
||||
oneWeek: "One week"
|
||||
oneMonth: "One month"
|
||||
oneYear: "One year"
|
||||
reflectMayTakeTime: "It may take some time for this to be reflected."
|
||||
failedToFetchAccountInformation: "Could not fetch account information"
|
||||
rateLimitExceeded: "Rate limit exceeded"
|
||||
|
|
14
packages/backend/migration/1709530777533-autoDeleteNotes.js
Normal file
14
packages/backend/migration/1709530777533-autoDeleteNotes.js
Normal 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";`);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
export class NoteSelfDestructInterval1709530777533 {
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE user_profile ADD "noteSelfDestructInterval" interval NOT NULL DEFAULT '1 months';`);
|
||||
await queryRunner.query(`ALTER TABLE user_profile ADD "noteSelfDestructEnable" boolean NOT NULL DEFAULT false;`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE user_profile DROP COLUMN "noteSelfDestructInterval";`);
|
||||
await queryRunner.query(`ALTER TABLE user_profile DROP COLUMN "noteSelfDestructEnable";`);
|
||||
}
|
||||
|
||||
}
|
|
@ -509,8 +509,8 @@ export class UserEntityService implements OnModuleInit {
|
|||
mutedWords: profile!.mutedWords,
|
||||
hardMutedWords: profile!.hardMutedWords,
|
||||
mutedInstances: profile!.mutedInstances,
|
||||
noteSelfDestructInterval: profile!.noteSelfDestructInterval,
|
||||
noteSelfDestructEnable: profile!.noteSelfDestructEnable,
|
||||
autoDeleteNotes: profile!.autoDeleteNotes,
|
||||
autoDeleteNotesMinutes: profile!.autoDeleteNotesMinutes,
|
||||
mutingNotificationTypes: [], // 後方互換性のため
|
||||
notificationRecieveConfig: profile!.notificationRecieveConfig,
|
||||
emailNotificationTypes: profile!.emailNotificationTypes,
|
||||
|
|
|
@ -343,4 +343,3 @@ export const descriptionSchema = { type: 'string', minLength: 1, maxLength: 1500
|
|||
export const locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||
export const listenbrainzSchema = { type: "string", minLength: 1, maxLength: 128 } as const;
|
||||
export const birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const;
|
||||
export const selfDestructIntervalSchema = { type: 'string', pattern: /^[1-9][0-9]+ (years|months|days|hours|minutes)$/.toString().slice(1, -1) } as const;
|
||||
|
|
|
@ -277,15 +277,15 @@ export class MiUserProfile {
|
|||
unlockedAt: number;
|
||||
}[];
|
||||
|
||||
@Column('interval', {
|
||||
default: '1 months',
|
||||
})
|
||||
public noteSelfDestructInterval: string;
|
||||
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
})
|
||||
public noteSelfDestructEnable: string;
|
||||
public autoDeleteNotes: boolean;
|
||||
|
||||
@Column('integer', {
|
||||
default: 43200, // 30 days in minutes
|
||||
})
|
||||
public autoDeleteNotesMinutes: number;
|
||||
|
||||
|
||||
//#region Denormalized fields
|
||||
|
|
|
@ -605,12 +605,12 @@ export const packedMeDetailedOnlySchema = {
|
|||
nullable: false, optional: false,
|
||||
},
|
||||
},
|
||||
noteSelfDestructInterval: {
|
||||
type: 'string',
|
||||
autoDeleteNotes: {
|
||||
type: 'boolean',
|
||||
nullable: false, optional: false,
|
||||
},
|
||||
noteSelfDestructEnable: {
|
||||
type: 'boolean',
|
||||
autoDeleteNotesMinutes: {
|
||||
type: 'number',
|
||||
nullable: false, optional: false,
|
||||
},
|
||||
notificationRecieveConfig: {
|
||||
|
|
|
@ -88,14 +88,14 @@ export const meta = {
|
|||
type: 'string',
|
||||
},
|
||||
},
|
||||
noteSelfDestructInterval: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
noteSelfDestructEnable: {
|
||||
autoDeleteNotes: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
autoDeleteNotesMinutes: {
|
||||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
notificationRecieveConfig: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
|
@ -247,8 +247,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
|
||||
mutedWords: profile.mutedWords,
|
||||
mutedInstances: profile.mutedInstances,
|
||||
noteSelfDestructInterval: profile.noteSelfDestructInterval,
|
||||
noteSelfDestructEnable: profile.noteSelfDestructEnable,
|
||||
autoDeleteNotesMinutes: profile.autoDeleteNotesMinutes,
|
||||
autoDeleteNotes: profile.autoDeleteNotes,
|
||||
notificationRecieveConfig: profile.notificationRecieveConfig,
|
||||
isModerator: isModerator,
|
||||
isSilenced: isSilenced,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { extractHashtags } from '@/misc/extract-hashtags.js';
|
|||
import * as Acct from '@/misc/acct.js';
|
||||
import type { UsersRepository, DriveFilesRepository, UserProfilesRepository, PagesRepository } from '@/models/_.js';
|
||||
import type { MiLocalUser, MiUser } from '@/models/User.js';
|
||||
import { birthdaySchema, listenbrainzSchema, descriptionSchema, locationSchema, nameSchema, selfDestructIntervalSchema } from '@/models/User.js';
|
||||
import { birthdaySchema, listenbrainzSchema, descriptionSchema, locationSchema, nameSchema } from '@/models/User.js';
|
||||
import type { MiUserProfile } from '@/models/UserProfile.js';
|
||||
import { notificationTypes } from '@/types.js';
|
||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||
|
@ -202,8 +202,8 @@ export const paramDef = {
|
|||
mutedInstances: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
noteSelfDestructInterval: { ...selfDestructIntervalSchema, nullable: false },
|
||||
noteSelfDestructEnable: { type: 'boolean', nullable: false },
|
||||
autoDeleteNotes: { type: 'boolean', nullable: false },
|
||||
autoDeleteNotesMinutes: { type: 'number', nullable: false, minimum: 1 },
|
||||
notificationRecieveConfig: {
|
||||
type: 'object',
|
||||
nullable: false,
|
||||
|
@ -321,8 +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.noteSelfDestructInterval !== undefined) profileUpdates.noteSelfDestructInterval = ps.noteSelfDestructInterval;
|
||||
if (ps.noteSelfDestructEnable !== undefined) profileUpdates.noteSelfDestructEnable = ps.noteSelfDestructEnable;
|
||||
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;
|
||||
|
|
66
packages/frontend/src/pages/settings/privacy.autodelete.vue
Normal file
66
packages/frontend/src/pages/settings/privacy.autodelete.vue
Normal file
|
@ -0,0 +1,66 @@
|
|||
<template>
|
||||
<div class="_gaps_m">
|
||||
<MkButton :disabled="!changed" :primary="changed" @click="save()"><i class="ph-check ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
|
||||
<MkSwitch v-model="enable">
|
||||
{{ i18n.ts.enable }}
|
||||
<template #caption>When enabled, notes you post will automatically delete themselves if they are older than the given threshold age.</template>
|
||||
</MkSwitch>
|
||||
<MkInput v-model="threshold" type="number" :min="1">
|
||||
<template #suffix>{{ i18n.ts._time.minute }}</template>
|
||||
<template #caption>Note age threshold</template>
|
||||
</MkInput>
|
||||
<MkFolder>
|
||||
<template #label>{{ i18n.ts.selectFromPresets }}</template>
|
||||
<FormSplit :minWidth="100">
|
||||
<MkButton @click="setThreshold(WEEK_MINUTES)" inline small>{{ i18n.ts.oneWeek }}</MkButton>
|
||||
<MkButton @click="setThreshold(MONTH_MINUTES)" inline small>{{ i18n.ts.oneMonth }}</MkButton>
|
||||
<MkButton @click="setThreshold(YEAR_MINUTES)" inline small>{{ i18n.ts.oneYear }}</MkButton>
|
||||
</FormSplit>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkSwitch from '@/components/MkSwitch.vue';
|
||||
import FormSplit from '@/components/form/split.vue';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { signinRequired } from '@/account.js';
|
||||
|
||||
const $i = signinRequired();
|
||||
|
||||
const enable = ref($i.autoDeleteNotes);
|
||||
const threshold = ref($i.autoDeleteNotesMinutes);
|
||||
|
||||
const changed = computed(() => enable.value !== $i.autoDeleteNotes || threshold.value !== $i.autoDeleteNotesMinutes);
|
||||
|
||||
const DAY_MINUTES = 60 * 24;
|
||||
const WEEK_MINUTES = 7 * DAY_MINUTES;
|
||||
const MONTH_MINUTES = 30 * DAY_MINUTES;
|
||||
const YEAR_MINUTES = 365 * DAY_MINUTES;
|
||||
|
||||
function setThreshold(value) {
|
||||
threshold.value = value;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (enable.value) {
|
||||
const { canceled } = await os.confirm({
|
||||
type: 'warning',
|
||||
text: 'This action may immediately delete notes older than the threshold value! Click ok to confirm.',
|
||||
});
|
||||
|
||||
if (canceled) return;
|
||||
}
|
||||
|
||||
misskeyApi('i/update', {
|
||||
autoDeleteNotes: !!enable.value,
|
||||
autoDeleteNotesMinutes: threshold.value,
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -72,24 +72,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<FormSection>
|
||||
<div class="_gaps_m">
|
||||
<MkFolder>
|
||||
<template #label>{{ i18n.ts.selfDestructingNotes }}</template>
|
||||
<div class="_gaps_m">
|
||||
<MkButton primary @click="save()"><i class="ph-check ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
|
||||
|
||||
<MkSwitch v-model="selfDestructingNotesEnable" manualSave>
|
||||
{{ i18n.ts.enable }}
|
||||
<template #caption>{{ i18n.ts._selfDestructingNotes.description }}</template>
|
||||
</MkSwitch>
|
||||
<FormSplit :minWidth="200">
|
||||
<MkInput v-model="selfDestructIntervalAmount" type="number" min="1" small/>
|
||||
<MkSelect v-model="selfDestructIntervalUnit" small>
|
||||
<option value="years">{{ i18n.ts._time.year }}</option>
|
||||
<option value="months">{{ i18n.ts._time.month }}</option>
|
||||
<option value="days">{{ i18n.ts._time.day }}</option>
|
||||
<option value="hours">{{ i18n.ts._time.hour }}</option>
|
||||
</MkSelect>
|
||||
</FormSplit>
|
||||
</div>
|
||||
<template #label>{{ i18n.ts.autoDeleteNotes }}</template>
|
||||
<XAutoDelete />
|
||||
</MkFolder>
|
||||
</div>
|
||||
</FormSection>
|
||||
|
@ -99,10 +83,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import MkSwitch from '@/components/MkSwitch.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkSelect from '@/components/MkSelect.vue';
|
||||
import FormSplit from '@/components/form/split.vue';
|
||||
import FormSection from '@/components/form/section.vue';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
|
@ -110,6 +91,7 @@ import { defaultStore } from '@/store.js';
|
|||
import { i18n } from '@/i18n.js';
|
||||
import { signinRequired } from '@/account.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import XAutoDelete from './privacy.autodelete.vue';
|
||||
|
||||
const $i = signinRequired();
|
||||
|
||||
|
@ -122,18 +104,12 @@ const hideOnlineStatus = ref($i.hideOnlineStatus);
|
|||
const publicReactions = ref($i.publicReactions);
|
||||
const followingVisibility = ref($i.followingVisibility);
|
||||
const followersVisibility = ref($i.followersVisibility);
|
||||
const selfDestructingNotesEnable = ref($i.selfDestructingNotesEnable);
|
||||
const selfDestructIntervalAmount = ref(1);
|
||||
const selfDestructIntervalUnit = ref('months');
|
||||
|
||||
const defaultNoteVisibility = computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
|
||||
const defaultNoteLocalOnly = computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
|
||||
const rememberNoteVisibility = computed(defaultStore.makeGetterSetter('rememberNoteVisibility'));
|
||||
const keepCw = computed(defaultStore.makeGetterSetter('keepCw'));
|
||||
|
||||
//console.log(i)
|
||||
//[ selfDestructIntervalAmount.value, selfDestructIntervalUnit.value ] = $i.selfDestructingNotesInterval.split(' ');
|
||||
|
||||
function save() {
|
||||
misskeyApi('i/update', {
|
||||
isLocked: !!isLocked.value,
|
||||
|
@ -148,10 +124,6 @@ function save() {
|
|||
});
|
||||
}
|
||||
|
||||
function saveSelfDestructSettings() {
|
||||
console.log('done');
|
||||
}
|
||||
|
||||
const headerActions = computed(() => []);
|
||||
|
||||
const headerTabs = computed(() => []);
|
||||
|
|
Loading…
Reference in a new issue