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