mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[backend] Don't recursively resolve user profile mentions
This commit is contained in:
parent
7c8881f1a8
commit
3b85491ee4
@ -170,6 +170,7 @@ export async function createPerson(
|
||||
uri: string,
|
||||
resolver?: Resolver,
|
||||
subjectHost?: string,
|
||||
skipMentions: boolean = false
|
||||
): Promise<User> {
|
||||
if (typeof uri !== "string") throw new Error("uri is not string");
|
||||
|
||||
@ -399,7 +400,7 @@ export async function createPerson(
|
||||
updateUsertags(user!, tags);
|
||||
|
||||
// Mentions update
|
||||
UserProfiles.updateMentions(user!.id);
|
||||
if (!skipMentions) UserProfiles.updateMentions(user!.id);
|
||||
|
||||
//#region Fetch avatar and header image
|
||||
const [avatar, banner] = await Promise.all(
|
||||
|
@ -30,7 +30,8 @@ export async function resolveUser(
|
||||
username: string,
|
||||
host: string | null,
|
||||
refresh: boolean = true,
|
||||
awaitRefresh: boolean = true
|
||||
awaitRefresh: boolean = true,
|
||||
skipMentionsOnCreate: boolean = false
|
||||
): Promise<User> {
|
||||
const usernameLower = username.toLowerCase();
|
||||
|
||||
@ -104,14 +105,14 @@ export async function resolveUser(
|
||||
// Otherwise create and return new user
|
||||
else {
|
||||
logger.succ(`return new remote user: ${chalk.magenta(finalAcctLower)}`);
|
||||
return await createPerson(fingerRes.self.href, undefined, subjectHost);
|
||||
return await createPerson(fingerRes.self.href, undefined, subjectHost, skipMentionsOnCreate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not a split domain setup, so we can simply create and return the new user
|
||||
logger.succ(`return new remote user: ${chalk.magenta(finalAcctLower)}`);
|
||||
return await createPerson(fingerRes.self.href, undefined, subjectHost);
|
||||
return await createPerson(fingerRes.self.href, undefined, subjectHost, skipMentionsOnCreate);
|
||||
}
|
||||
|
||||
// If user information is out of date, return it by starting over from WebFinger
|
||||
@ -187,7 +188,7 @@ export async function resolveUser(
|
||||
} else if (refresh && !awaitRefresh && (user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24)) {
|
||||
// Run the refresh in the background
|
||||
// noinspection ES6MissingAwait
|
||||
resolveUser(username, host, true, true);
|
||||
resolveUser(username, host, true, true, skipMentionsOnCreate);
|
||||
}
|
||||
|
||||
logger.info(`return existing remote user: ${acctLower}`);
|
||||
@ -197,7 +198,7 @@ export async function resolveUser(
|
||||
export async function resolveMentionToUserAndProfile(username: string, host: string | null, objectHost: string | null) {
|
||||
return profileMentionCache.fetch(`${username}@${host ?? objectHost}`, async () => {
|
||||
try {
|
||||
const user = await resolveUser(username, host ?? objectHost, false);
|
||||
const user = await resolveUser(username, host ?? objectHost, false, false, true);
|
||||
const profile = await UserProfiles.findOneBy({ userId: user.id });
|
||||
const data = { username, host: host ?? objectHost };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user