fix: removal condition fetching
This commit is contained in:
parent
a5fd3dd7fc
commit
c28afda4bf
@ -428,7 +428,9 @@ 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) {
|
||||
|
@ -5,8 +5,10 @@
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { AutoRemovalConditionRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { AutoRemovalConditionRepository, MiAutoRemovalCondition, UsersRepository } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['account'],
|
||||
@ -47,6 +49,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private globalEventService: GlobalEventService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
await this.usersRepository.update(me.id, { autoRemoval: ps.active });
|
||||
@ -55,7 +60,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
noPiningNotes: ps.noPiningNotes,
|
||||
noSpecifiedNotes: ps.noSpecifiedNotes,
|
||||
};
|
||||
await this.autoRemovalConditionRepository.update(me.autoRemovalConditionId, updated);
|
||||
const updates = {} as Partial<MiAutoRemovalCondition>;
|
||||
if (ps.deleteAfter !== undefined) updates.deleteAfter = ps.deleteAfter;
|
||||
if (ps.noPiningNotes !== undefined) updates.noPiningNotes = ps.noPiningNotes;
|
||||
if (ps.noSpecifiedNotes !== undefined) updates.noSpecifiedNotes = ps.noSpecifiedNotes;
|
||||
if (Object.keys(updates).length > 0) await this.autoRemovalConditionRepository.update(me.autoRemovalConditionId, updated);
|
||||
|
||||
const iObj = await this.userEntityService.pack(me.id, me, {
|
||||
schema: 'MeDetailed',
|
||||
includeSecrets: true,
|
||||
});
|
||||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', iObj);
|
||||
|
||||
return iObj;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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" :type="'number'" :placeholder="'7'" :required="true">
|
||||
<template #label>{{ i18n.ts._autoRemoval.deleteAfter }}</template>
|
||||
<template #caption>{{ i18n.ts._autoRemoval.deleteAfterDescription }}</template>
|
||||
</MkInput>
|
||||
@ -103,6 +103,7 @@ 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 MkButton from '@/components/MkButton.vue';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
@ -120,10 +121,10 @@ const hideOnlineStatus = ref($i.hideOnlineStatus);
|
||||
const publicReactions = ref($i.publicReactions);
|
||||
const followingVisibility = ref($i.followingVisibility);
|
||||
const followersVisibility = ref($i.followersVisibility);
|
||||
const autoRemoval = ref($i.autoRemovalCondition.active);
|
||||
const deleteAfter = ref($i.autoRemovalCondition.deleteAfter);
|
||||
const noPiningNotes = ref($i.autoRemovalCondition.noPiningNotes);
|
||||
const noSpecifiedNotes = ref($i.autoRemovalCondition.noSpecifiedNotes);
|
||||
const autoRemoval = ref<boolean>($i.autoRemovalCondition.active);
|
||||
const deleteAfter = ref<number>($i.autoRemovalCondition.deleteAfter || 7);
|
||||
const noPiningNotes = ref<boolean>($i.autoRemovalCondition.noPiningNotes);
|
||||
const noSpecifiedNotes = ref<boolean>($i.autoRemovalCondition.noSpecifiedNotes);
|
||||
|
||||
const defaultNoteVisibility = computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
|
||||
const defaultNoteLocalOnly = computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
|
||||
|
Loading…
Reference in New Issue
Block a user