fix: removal object fetching
This commit is contained in:
parent
82a7cdb204
commit
a5fd3dd7fc
8 changed files with 24 additions and 22 deletions
|
@ -151,7 +151,9 @@ export class SignupService {
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: this.utilityService.toPunyNullable(host),
|
host: this.utilityService.toPunyNullable(host),
|
||||||
token: secret,
|
token: secret,
|
||||||
|
autoRemoval: false,
|
||||||
autoRemovalConditionId: condition.id,
|
autoRemovalConditionId: condition.id,
|
||||||
|
autoRemovalCondition: condition,
|
||||||
isRoot: isTheFirstUser,
|
isRoot: isTheFirstUser,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ export class AutoRemovalConditionEntityService {
|
||||||
const condition = typeof src === 'object' ? src : await this.autoRemovalConditionRepository.findOneByOrFail({ id: src });
|
const condition = typeof src === 'object' ? src : await this.autoRemovalConditionRepository.findOneByOrFail({ id: src });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: condition.id,
|
|
||||||
deleteAfter: condition.deleteAfter,
|
deleteAfter: condition.deleteAfter,
|
||||||
noPiningNotes: condition.noPiningNotes,
|
noPiningNotes: condition.noPiningNotes,
|
||||||
noSpecifiedNotes: condition.noSpecifiedNotes,
|
noSpecifiedNotes: condition.noSpecifiedNotes,
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
passwordSchema,
|
passwordSchema,
|
||||||
} from '@/models/User.js';
|
} from '@/models/User.js';
|
||||||
import type {
|
import type {
|
||||||
|
AutoRemovalConditionRepository,
|
||||||
BlockingsRepository,
|
BlockingsRepository,
|
||||||
FollowingsRepository,
|
FollowingsRepository,
|
||||||
FollowRequestsRepository,
|
FollowRequestsRepository,
|
||||||
|
@ -134,6 +135,9 @@ export class UserEntityService implements OnModuleInit {
|
||||||
|
|
||||||
@Inject(DI.userMemosRepository)
|
@Inject(DI.userMemosRepository)
|
||||||
private userMemosRepository: UserMemoRepository,
|
private userMemosRepository: UserMemoRepository,
|
||||||
|
|
||||||
|
@Inject(DI.autoRemovalConditionRepository)
|
||||||
|
private autoRemovalConditionRepository: AutoRemovalConditionRepository,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +428,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
const profile = isDetailed
|
const profile = isDetailed
|
||||||
? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id }))
|
? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id }))
|
||||||
: null;
|
: null;
|
||||||
|
const autoRemovalCondition = await this.autoRemovalConditionRepository.findOneBy({ id: user.autoRemovalConditionId });
|
||||||
let relation: UserRelation | null = null;
|
let relation: UserRelation | null = null;
|
||||||
if (meId && !isMe && isDetailed) {
|
if (meId && !isMe && isDetailed) {
|
||||||
if (opts.userRelations) {
|
if (opts.userRelations) {
|
||||||
|
@ -612,8 +616,12 @@ export class UserEntityService implements OnModuleInit {
|
||||||
notificationRecieveConfig: profile?.notificationRecieveConfig,
|
notificationRecieveConfig: profile?.notificationRecieveConfig,
|
||||||
emailNotificationTypes: profile?.emailNotificationTypes,
|
emailNotificationTypes: profile?.emailNotificationTypes,
|
||||||
achievements: profile?.achievements,
|
achievements: profile?.achievements,
|
||||||
autoRemoval: user.autoRemoval,
|
autoRemovalCondition: {
|
||||||
autoRemovalCondition: user.autoRemovalCondition,
|
active: user.autoRemoval,
|
||||||
|
deleteAfter: autoRemovalCondition?.deleteAfter,
|
||||||
|
noPiningNotes: autoRemovalCondition?.noPiningNotes,
|
||||||
|
noSpecifiedNotes: autoRemovalCondition?.noSpecifiedNotes,
|
||||||
|
},
|
||||||
loggedInDays: profile?.loggedInDates.length,
|
loggedInDays: profile?.loggedInDates.length,
|
||||||
policies: policies,
|
policies: policies,
|
||||||
} : {}),
|
} : {}),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Entity, Column, PrimaryColumn, Index } from 'typeorm';
|
import { Entity, Column, PrimaryColumn } from 'typeorm';
|
||||||
import { id } from './util/id.js';
|
import { id } from './util/id.js';
|
||||||
|
|
||||||
@Entity('auto_removal_condition')
|
@Entity('auto_removal_condition')
|
||||||
|
|
|
@ -6,12 +6,6 @@
|
||||||
export const packedAutoRemovalConditionSchema = {
|
export const packedAutoRemovalConditionSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
format: 'id',
|
|
||||||
example: 'xxxxxxxxxx',
|
|
||||||
},
|
|
||||||
deleteAfter: {
|
deleteAfter: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
optional: true, nullable: false,
|
optional: true, nullable: false,
|
||||||
|
|
|
@ -641,19 +641,13 @@ export const packedMeDetailedOnlySchema = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
autoRemoval: {
|
|
||||||
type: 'boolean',
|
|
||||||
nullable: false, optional: false,
|
|
||||||
},
|
|
||||||
autoRemovalCondition: {
|
autoRemovalCondition: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
nullable: false, optional: false,
|
nullable: false, optional: false,
|
||||||
properties: {
|
properties: {
|
||||||
id: {
|
active: {
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
nullable: false, optional: false,
|
nullable: false, optional: false,
|
||||||
format: 'id',
|
|
||||||
example: 'xxxxxxxxxx',
|
|
||||||
},
|
},
|
||||||
deleteAfter: {
|
deleteAfter: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
await this.usersRepository.update(me.id, { autoRemoval: false });
|
await this.usersRepository.update(me.id, { autoRemoval: ps.active });
|
||||||
const updated = {
|
const updated = {
|
||||||
deleteAfter: ps.deleteAfter,
|
deleteAfter: ps.deleteAfter,
|
||||||
noPiningNotes: ps.noPiningNotes,
|
noPiningNotes: ps.noPiningNotes,
|
||||||
|
|
|
@ -75,7 +75,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSwitch v-model="autoRemoval">{{ i18n.ts._autoRemoval.use }}</MkSwitch>
|
<MkSwitch v-model="autoRemoval">{{ i18n.ts._autoRemoval.use }}</MkSwitch>
|
||||||
|
|
||||||
<template v-if="autoRemoval">
|
<template v-if="autoRemoval">
|
||||||
<MkInput v-model="deleteAfter" :placeholder="7">
|
<MkInput v-model="deleteAfter" :placeholder="'7'">
|
||||||
<template #label>{{ i18n.ts._autoRemoval.deleteAfter }}</template>
|
<template #label>{{ i18n.ts._autoRemoval.deleteAfter }}</template>
|
||||||
<template #caption>{{ i18n.ts._autoRemoval.deleteAfterDescription }}</template>
|
<template #caption>{{ i18n.ts._autoRemoval.deleteAfterDescription }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
|
@ -90,6 +90,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #caption>{{ i18n.ts._autoRemoval.noSpecifiedNotesDescription }}</template>
|
<template #caption>{{ i18n.ts._autoRemoval.noSpecifiedNotesDescription }}</template>
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</template>
|
</template>
|
||||||
|
<MkButton primary class="save" @click="saveRemovalCondition"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
</div>
|
</div>
|
||||||
|
@ -101,6 +102,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
import MkSelect from '@/components/MkSelect.vue';
|
import MkSelect from '@/components/MkSelect.vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import MkFolder from '@/components/MkFolder.vue';
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
@ -118,7 +120,7 @@ const hideOnlineStatus = ref($i.hideOnlineStatus);
|
||||||
const publicReactions = ref($i.publicReactions);
|
const publicReactions = ref($i.publicReactions);
|
||||||
const followingVisibility = ref($i.followingVisibility);
|
const followingVisibility = ref($i.followingVisibility);
|
||||||
const followersVisibility = ref($i.followersVisibility);
|
const followersVisibility = ref($i.followersVisibility);
|
||||||
const autoRemoval = ref($i.autoRemoval);
|
const autoRemoval = ref($i.autoRemovalCondition.active);
|
||||||
const deleteAfter = ref($i.autoRemovalCondition.deleteAfter);
|
const deleteAfter = ref($i.autoRemovalCondition.deleteAfter);
|
||||||
const noPiningNotes = ref($i.autoRemovalCondition.noPiningNotes);
|
const noPiningNotes = ref($i.autoRemovalCondition.noPiningNotes);
|
||||||
const noSpecifiedNotes = ref($i.autoRemovalCondition.noSpecifiedNotes);
|
const noSpecifiedNotes = ref($i.autoRemovalCondition.noSpecifiedNotes);
|
||||||
|
@ -140,6 +142,9 @@ function save() {
|
||||||
followingVisibility: followingVisibility.value,
|
followingVisibility: followingVisibility.value,
|
||||||
followersVisibility: followersVisibility.value,
|
followersVisibility: followersVisibility.value,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveRemovalCondition() {
|
||||||
misskeyApi('i/update-removal-condition', {
|
misskeyApi('i/update-removal-condition', {
|
||||||
active: autoRemoval.value,
|
active: autoRemoval.value,
|
||||||
deleteAfter: deleteAfter.value,
|
deleteAfter: deleteAfter.value,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue