mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
[mastodon-client] Fix user profile aggregate when only target is self
This commit is contained in:
parent
f350755721
commit
5490137f44
1 changed files with 13 additions and 9 deletions
|
@ -126,19 +126,23 @@ export class UserConverter {
|
||||||
const userProfileAggregate = new Map<User["id"], UserProfile | null>();
|
const userProfileAggregate = new Map<User["id"], UserProfile | null>();
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
|
const targetsWithoutSelf = targets.filter(u => u !== user.id);
|
||||||
|
|
||||||
|
if (targetsWithoutSelf.length > 0) {
|
||||||
const followings = await Followings.createQueryBuilder('following')
|
const followings = await Followings.createQueryBuilder('following')
|
||||||
.select('following.followeeId')
|
.select('following.followeeId')
|
||||||
.where('following.followerId = :meId', { meId: user.id })
|
.where('following.followerId = :meId', { meId: user.id })
|
||||||
.andWhere('following.followeeId IN (:...targets)', { targets: targets.filter(u => u !== user.id) })
|
.andWhere('following.followeeId IN (:...targets)', { targets: targetsWithoutSelf })
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
followedOrSelfAggregate.set(user.id, true);
|
for (const userId of targetsWithoutSelf) {
|
||||||
|
|
||||||
for (const userId of targets.filter(u => u !== user.id)) {
|
|
||||||
followedOrSelfAggregate.set(userId, !!followings.find(f => f.followerId === userId));
|
followedOrSelfAggregate.set(userId, !!followings.find(f => f.followerId === userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
followedOrSelfAggregate.set(user.id, true);
|
||||||
|
}
|
||||||
|
|
||||||
const profiles = await UserProfiles.findBy({
|
const profiles = await UserProfiles.findBy({
|
||||||
userId: In(targets)
|
userId: In(targets)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue