mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 01:47:39 -07:00
[backend] Don't refresh user data in resolveMentionWithFallback
This commit is contained in:
parent
ce29c1dce2
commit
588a39f17a
1 changed files with 6 additions and 3 deletions
|
@ -17,6 +17,7 @@ const uriHostCache = new Cache<string>("resolveUserUriHost", 60 * 60 * 24);
|
|||
export async function resolveUser(
|
||||
username: string,
|
||||
host: string | null,
|
||||
refresh: boolean = true
|
||||
): Promise<User> {
|
||||
const usernameLower = username.toLowerCase();
|
||||
|
||||
|
@ -102,8 +103,10 @@ export async function resolveUser(
|
|||
|
||||
// If user information is out of date, return it by starting over from WebFilger
|
||||
if (
|
||||
refresh && (
|
||||
user.lastFetchedAt == null ||
|
||||
Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24
|
||||
)
|
||||
) {
|
||||
// Prevent multiple attempts to connect to unconnected instances, update before each attempt to prevent subsequent similar attempts
|
||||
await Users.update(user.id, {
|
||||
|
@ -180,7 +183,7 @@ export async function resolveMentionWithFallback(username: string, host: string
|
|||
if (cached) return cached.url ?? cached.uri;
|
||||
if (host === null || host === config.domain) return fallback;
|
||||
try {
|
||||
const user = await resolveUser(username, host);
|
||||
const user = await resolveUser(username, host, false);
|
||||
const profile = await UserProfiles.findOneBy({ userId: user.id });
|
||||
return profile?.url ?? user.uri ?? fallback;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue