fix: update cache
This commit is contained in:
parent
bd7dab44c0
commit
5e802df4c9
2 changed files with 26 additions and 0 deletions
|
@ -9,6 +9,7 @@ import deleteFollowing from "@/services/following/delete.js";
|
|||
|
||||
import type { IMove } from "../../type.js";
|
||||
import { getApHrefNullable } from "../../type.js";
|
||||
import { userByIdCache, userDenormalizedCache } from "@/services/user-cache.js";
|
||||
|
||||
export default async (
|
||||
actor: CacheableRemoteUser,
|
||||
|
@ -45,6 +46,19 @@ export default async (
|
|||
}
|
||||
|
||||
// add target uri to movedToUri in order to indicate that the user has moved
|
||||
await userByIdCache.get(old_acc.id).then((cached) => {
|
||||
if (cached) {
|
||||
userByIdCache.set(cached.id, { ...cached, movedToUri: targetUri });
|
||||
}
|
||||
});
|
||||
await userDenormalizedCache.get(old_acc.id).then((cached) => {
|
||||
if (cached) {
|
||||
userDenormalizedCache.set(cached.id, {
|
||||
...cached,
|
||||
movedToUri: targetUri,
|
||||
});
|
||||
}
|
||||
});
|
||||
await Users.update(old_acc.id, { movedToUri: targetUri });
|
||||
|
||||
// follow the new account and unfollow the old one
|
||||
|
|
|
@ -13,6 +13,7 @@ import { Followings, Users } from "@/models/index.js";
|
|||
import config from "@/config/index.js";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
import { parse } from "@/misc/acct.js";
|
||||
import { userByIdCache, userDenormalizedCache } from "@/services/user-cache.js";
|
||||
|
||||
export const meta = {
|
||||
tags: ["users"],
|
||||
|
@ -127,7 +128,18 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
updates.movedToUri = toUrl;
|
||||
updates.alsoKnownAs = user.alsoKnownAs?.concat(toUrl) ?? [toUrl];
|
||||
|
||||
await userByIdCache.get(user.id).then((cached) => {
|
||||
if (cached) {
|
||||
userByIdCache.set(cached.id, { ...cached, ...updates });
|
||||
}
|
||||
});
|
||||
await userDenormalizedCache.get(user.id).then((cached) => {
|
||||
if (cached) {
|
||||
userDenormalizedCache.set(cached.id, { ...cached, ...updates });
|
||||
}
|
||||
});
|
||||
await Users.update(user.id, updates);
|
||||
|
||||
const iObj = await Users.pack<true, true>(user.id, user, {
|
||||
detail: true,
|
||||
includeSecrets: true,
|
||||
|
|
Loading…
Reference in a new issue