mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -07:00
[mastodon-client] Also refresh user profile data on /accounts/:id
This commit is contained in:
parent
7c7c6a09a2
commit
34376b0718
1 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Note } from "@/models/entities/note.js";
|
||||
import { ILocalUser, User } from "@/models/entities/user.js";
|
||||
import { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js";
|
||||
import {
|
||||
Blockings,
|
||||
Followings,
|
||||
|
@ -42,6 +42,7 @@ import { verifyLink } from "@/services/fetch-rel-me.js";
|
|||
import { MastoApiError } from "@/server/api/mastodon/middleware/catch-errors.js";
|
||||
import { MastoContext } from "@/server/api/mastodon/index.js";
|
||||
import { resolveUser } from "@/remote/resolve-user.js";
|
||||
import { updatePerson } from "@/remote/activitypub/models/person.js";
|
||||
|
||||
export type AccountCache = {
|
||||
locks: AsyncLock;
|
||||
|
@ -515,9 +516,18 @@ export class UserHelpers {
|
|||
public static async getUserOr404(id: string): Promise<User> {
|
||||
return getUser(id).catch(_ => {
|
||||
throw new MastoApiError(404);
|
||||
}).then(u => {
|
||||
this.updateUserInBackground(u);
|
||||
return u;
|
||||
});
|
||||
}
|
||||
|
||||
public static updateUserInBackground(user: User) {
|
||||
if (Users.isLocalUser(user)) return;
|
||||
// noinspection JSIgnoredPromiseFromCall
|
||||
updatePerson(user.uri!, undefined, undefined, user as IRemoteUser);
|
||||
}
|
||||
|
||||
public static getFreshAccountCache(): AccountCache {
|
||||
return {
|
||||
locks: new AsyncLock(),
|
||||
|
|
Loading…
Reference in a new issue