mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
merge: fix some regressions due to recent merges (!1112)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1112 Approved-by: Hazelnoot <acomputerdog@gmail.com> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
ec5ea3cf17
3 changed files with 10 additions and 33 deletions
|
@ -964,6 +964,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
|
|
||||||
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
||||||
for (const following of followings) {
|
for (const following of followings) {
|
||||||
|
if (following.followerHost !== null) continue;
|
||||||
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
||||||
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
||||||
|
|
||||||
|
|
|
@ -849,6 +849,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
|
|
||||||
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
||||||
for (const following of followings) {
|
for (const following of followings) {
|
||||||
|
if (following.followerHost !== null) continue;
|
||||||
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
||||||
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
||||||
|
|
||||||
|
|
|
@ -432,8 +432,6 @@ export class UserEntityService implements OnModuleInit {
|
||||||
userIdsByUri?: Map<string, string>,
|
userIdsByUri?: Map<string, string>,
|
||||||
instances?: Map<string, MiInstance | null>,
|
instances?: Map<string, MiInstance | null>,
|
||||||
securityKeyCounts?: Map<string, number>,
|
securityKeyCounts?: Map<string, number>,
|
||||||
pendingReceivedFollows?: Set<string>,
|
|
||||||
pendingSentFollows?: Set<string>,
|
|
||||||
},
|
},
|
||||||
): Promise<Packed<S>> {
|
): Promise<Packed<S>> {
|
||||||
const opts = Object.assign({
|
const opts = Object.assign({
|
||||||
|
@ -679,8 +677,8 @@ export class UserEntityService implements OnModuleInit {
|
||||||
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
|
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
|
||||||
hasUnreadChannel: false, // 後方互換性のため
|
hasUnreadChannel: false, // 後方互換性のため
|
||||||
hasUnreadNotification: notificationsInfo?.hasUnread, // 後方互換性のため
|
hasUnreadNotification: notificationsInfo?.hasUnread, // 後方互換性のため
|
||||||
hasPendingReceivedFollowRequest: opts.pendingReceivedFollows?.has(user.id) ?? this.getHasPendingReceivedFollowRequest(user.id),
|
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
|
||||||
hasPendingSentFollowRequest: opts.pendingSentFollows?.has(user.id) ?? this.getHasPendingSentFollowRequest(user.id),
|
hasPendingSentFollowRequest: this.getHasPendingSentFollowRequest(user.id),
|
||||||
unreadNotificationsCount: notificationsInfo?.unreadCount,
|
unreadNotificationsCount: notificationsInfo?.unreadCount,
|
||||||
mutedWords: profile!.mutedWords,
|
mutedWords: profile!.mutedWords,
|
||||||
hardMutedWords: profile!.hardMutedWords,
|
hardMutedWords: profile!.hardMutedWords,
|
||||||
|
@ -761,11 +759,8 @@ export class UserEntityService implements OnModuleInit {
|
||||||
|
|
||||||
const iAmModerator = await this.roleService.isModerator(me as MiUser);
|
const iAmModerator = await this.roleService.isModerator(me as MiUser);
|
||||||
const meId = me ? me.id : null;
|
const meId = me ? me.id : null;
|
||||||
const isMe = meId && _userIds.includes(meId);
|
|
||||||
const isDetailed = options && options.schema !== 'UserLite';
|
const isDetailed = options && options.schema !== 'UserLite';
|
||||||
const isDetailedAndMe = isDetailed && isMe;
|
const isDetailedAndMod = isDetailed && iAmModerator;
|
||||||
const isDetailedAndMeOrMod = isDetailed && (isMe || iAmModerator);
|
|
||||||
const isDetailedAndNotMe = isDetailed && !isMe;
|
|
||||||
|
|
||||||
const userUris = new Set(_users
|
const userUris = new Set(_users
|
||||||
.flatMap(user => [user.uri, user.movedToUri])
|
.flatMap(user => [user.uri, user.movedToUri])
|
||||||
|
@ -787,14 +782,14 @@ export class UserEntityService implements OnModuleInit {
|
||||||
|
|
||||||
// -- 実行者の有無や指定スキーマの種別によって要否が異なる値群を取得
|
// -- 実行者の有無や指定スキーマの種別によって要否が異なる値群を取得
|
||||||
|
|
||||||
const [profilesMap, userMemos, userRelations, pinNotes, userIdsByUri, instances, securityKeyCounts, pendingReceivedFollows, pendingSentFollows] = await Promise.all([
|
const [profilesMap, userMemos, userRelations, pinNotes, userIdsByUri, instances, securityKeyCounts] = await Promise.all([
|
||||||
// profilesMap
|
// profilesMap
|
||||||
this.cacheService.userProfileCache.fetchMany(_profilesToFetch).then(profiles => new Map(profiles.concat(_profilesFromUsers))),
|
this.cacheService.userProfileCache.fetchMany(_profilesToFetch).then(profiles => new Map(profiles.concat(_profilesFromUsers))),
|
||||||
// userMemos
|
// userMemos
|
||||||
isDetailed && meId ? this.userMemosRepository.findBy({ userId: meId })
|
isDetailed && meId ? this.userMemosRepository.findBy({ userId: meId })
|
||||||
.then(memos => new Map(memos.map(memo => [memo.targetUserId, memo.memo]))) : new Map(),
|
.then(memos => new Map(memos.map(memo => [memo.targetUserId, memo.memo]))) : new Map(),
|
||||||
// userRelations
|
// userRelations
|
||||||
isDetailedAndNotMe && meId ? this.getRelations(meId, _userIds) : new Map(),
|
isDetailed && meId ? this.getRelations(meId, _userIds) : new Map(),
|
||||||
// pinNotes
|
// pinNotes
|
||||||
isDetailed ? this.userNotePiningsRepository.createQueryBuilder('pin')
|
isDetailed ? this.userNotePiningsRepository.createQueryBuilder('pin')
|
||||||
.where('pin.userId IN (:...userIds)', { userIds: _userIds })
|
.where('pin.userId IN (:...userIds)', { userIds: _userIds })
|
||||||
|
@ -828,7 +823,7 @@ export class UserEntityService implements OnModuleInit {
|
||||||
Promise.all(Array.from(userHosts).map(async host => [host, await this.federatedInstanceService.fetch(host)] as const))
|
Promise.all(Array.from(userHosts).map(async host => [host, await this.federatedInstanceService.fetch(host)] as const))
|
||||||
.then(hosts => new Map(hosts)),
|
.then(hosts => new Map(hosts)),
|
||||||
// securityKeyCounts
|
// securityKeyCounts
|
||||||
isDetailedAndMeOrMod ? this.userSecurityKeysRepository.createQueryBuilder('key')
|
isDetailedAndMod ? this.userSecurityKeysRepository.createQueryBuilder('key')
|
||||||
.select('key.userId', 'userId')
|
.select('key.userId', 'userId')
|
||||||
.addSelect('count(key.id)', 'userCount')
|
.addSelect('count(key.id)', 'userCount')
|
||||||
.where({
|
.where({
|
||||||
|
@ -836,26 +831,8 @@ export class UserEntityService implements OnModuleInit {
|
||||||
})
|
})
|
||||||
.groupBy('key.userId')
|
.groupBy('key.userId')
|
||||||
.getRawMany<{ userId: string, userCount: number }>()
|
.getRawMany<{ userId: string, userCount: number }>()
|
||||||
.then(counts => new Map(counts.map(c => [c.userId, c.userCount]))) : new Map(),
|
.then(counts => new Map(counts.map(c => [c.userId, c.userCount])))
|
||||||
// TODO optimization: cache follow requests
|
: undefined, // .pack will fetch the keys for the requesting user if it's in the _userIds
|
||||||
// pendingReceivedFollows
|
|
||||||
isDetailedAndMe ? this.followRequestsRepository.createQueryBuilder('req')
|
|
||||||
.select('req.followeeId', 'followeeId')
|
|
||||||
.where({
|
|
||||||
followeeId: In(_userIds),
|
|
||||||
})
|
|
||||||
.groupBy('req.followeeId')
|
|
||||||
.getRawMany<{ followeeId: string }>()
|
|
||||||
.then(reqs => new Set(reqs.map(r => r.followeeId))) : new Set<string>(),
|
|
||||||
// pendingSentFollows
|
|
||||||
isDetailedAndMe ? this.followRequestsRepository.createQueryBuilder('req')
|
|
||||||
.select('req.followerId', 'followerId')
|
|
||||||
.where({
|
|
||||||
followerId: In(_userIds),
|
|
||||||
})
|
|
||||||
.groupBy('req.followerId')
|
|
||||||
.getRawMany<{ followerId: string }>()
|
|
||||||
.then(reqs => new Set(reqs.map(r => r.followerId))) : new Set<string>(),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
|
@ -872,8 +849,6 @@ export class UserEntityService implements OnModuleInit {
|
||||||
userIdsByUri,
|
userIdsByUri,
|
||||||
instances,
|
instances,
|
||||||
securityKeyCounts,
|
securityKeyCounts,
|
||||||
pendingReceivedFollows,
|
|
||||||
pendingSentFollows,
|
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue