summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/i/update.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-04-04 17:32:09 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-04-04 17:32:09 +0900
commitecaf152b4a6eb702375debaef0dddc2cca798116 (patch)
tree85b2ca34a67ad66368fea84d0462b5c109b22415 /packages/backend/src/server/api/endpoints/i/update.ts
parentrefactor(backend): rename Cache -> MemoryCache (diff)
downloadsharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.tar.gz
sharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.tar.bz2
sharkey-ecaf152b4a6eb702375debaef0dddc2cca798116.zip
enhance(backend): improve cache
Diffstat (limited to 'packages/backend/src/server/api/endpoints/i/update.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/i/update.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts
index b1eaab3908..46b16e9dce 100644
--- a/packages/backend/src/server/api/endpoints/i/update.ts
+++ b/packages/backend/src/server/api/endpoints/i/update.ts
@@ -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) {