enhance(backend): improve cache
This commit is contained in:
@@ -34,7 +34,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const freshUser = await this.usersRepository.findOneByOrFail({ id: me.id });
|
||||
const oldToken = freshUser.token;
|
||||
const oldToken = freshUser.token!;
|
||||
|
||||
const profile = await this.userProfilesRepository.findOneByOrFail({ userId: me.id });
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
||||
import { HashtagService } from '@/core/HashtagService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
@@ -152,6 +153,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
private accountUpdateService: AccountUpdateService,
|
||||
private hashtagService: HashtagService,
|
||||
private roleService: RoleService,
|
||||
private cacheService: CacheService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, _user, token) => {
|
||||
const user = await this.usersRepository.findOneByOrFail({ id: _user.id });
|
||||
@@ -276,9 +278,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
includeSecrets: isSecure,
|
||||
});
|
||||
|
||||
const updatedProfile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });
|
||||
|
||||
this.cacheService.userProfileCache.set(user.id, updatedProfile);
|
||||
|
||||
// Publish meUpdated event
|
||||
this.globalEventService.publishMainStream(user.id, 'meUpdated', iObj);
|
||||
this.globalEventService.publishUserEvent(user.id, 'updateUserProfile', await this.userProfilesRepository.findOneByOrFail({ userId: user.id }));
|
||||
this.globalEventService.publishUserEvent(user.id, 'updateUserProfile', updatedProfile);
|
||||
|
||||
// 鍵垢を解除したとき、溜まっていたフォローリクエストがあるならすべて承認
|
||||
if (user.isLocked && ps.isLocked === false) {
|
||||
|
@@ -7,6 +7,7 @@ import type { Muting } from '@/models/entities/Muting.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { GetterService } from '@/server/api/GetterService.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
@@ -65,6 +66,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
private globalEventService: GlobalEventService,
|
||||
private getterService: GetterService,
|
||||
private idService: IdService,
|
||||
private cacheService: CacheService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const muter = me;
|
||||
@@ -103,6 +105,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
muteeId: mutee.id,
|
||||
} as Muting);
|
||||
|
||||
this.cacheService.userMutingsCache.delete(muter.id);
|
||||
this.globalEventService.publishUserEvent(me.id, 'mute', mutee);
|
||||
});
|
||||
}
|
||||
|
@@ -92,8 +92,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
muterId: muter.id,
|
||||
muteeId: mutee.id,
|
||||
} as RenoteMuting);
|
||||
|
||||
// publishUserEvent(user.id, 'mute', mutee);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user