populate userProfile in more places

This commit is contained in:
Hazelnoot 2025-06-06 02:48:49 -04:00
parent bd8cd8c4e4
commit c9884a74fc
2 changed files with 21 additions and 6 deletions

View file

@ -589,9 +589,24 @@ export class NoteEntityService implements OnModuleInit {
id: In(targetNotesToFetch), id: In(targetNotesToFetch),
}, },
relations: { relations: {
user: true, user: {
reply: true, userProfile: true,
renote: true, },
reply: {
user: {
userProfile: true,
},
},
renote: {
user: {
userProfile: true,
},
reply: {
user: {
userProfile: true,
},
},
},
channel: true, channel: true,
}, },
}); });

View file

@ -789,11 +789,11 @@ export class UserEntityService implements OnModuleInit {
.map(user => user.host) .map(user => user.host)
.filter((host): host is string => host != null)); .filter((host): host is string => host != null));
const _profiles: MiUserProfile[] = []; const _profilesFromUsers: MiUserProfile[] = [];
const _profilesToFetch: string[] = []; const _profilesToFetch: string[] = [];
for (const user of _users) { for (const user of _users) {
if (user.userProfile) { if (user.userProfile) {
_profiles.push(user.userProfile); _profilesFromUsers.push(user.userProfile);
} else { } else {
_profilesToFetch.push(user.id); _profilesToFetch.push(user.id);
} }
@ -805,7 +805,7 @@ export class UserEntityService implements OnModuleInit {
// profilesMap // profilesMap
this.cacheService.getUserProfiles(_profilesToFetch) this.cacheService.getUserProfiles(_profilesToFetch)
.then(profiles => { .then(profiles => {
for (const profile of _profiles) { for (const profile of _profilesFromUsers) {
profiles.set(profile.userId, profile); profiles.set(profile.userId, profile);
} }
return profiles; return profiles;