|
|
|
@@ -743,6 +743,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|
|
|
|
if (renote.channelId != null) {
|
|
|
|
|
if (renote.replyId == null) {
|
|
|
|
|
this.featuredService.updateInChannelNotesRanking(renote.channelId, renote.id, 5);
|
|
|
|
|
this.featuredService.updatePerUserNotesRanking(renote.userId, renote.id, 5);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (renote.visibility === 'public' && renote.userHost == null && renote.replyId == null) {
|
|
|
|
@@ -843,25 +844,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|
|
|
|
|
|
|
|
|
const r = this.redisForTimelines.pipeline();
|
|
|
|
|
|
|
|
|
|
if (note.channelId) {
|
|
|
|
|
this.funoutTimelineService.push(`channelTimeline:${note.channelId}`, note.id, this.config.perChannelMaxNoteCacheCount, r);
|
|
|
|
|
|
|
|
|
|
this.funoutTimelineService.push(`userTimelineWithChannel:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r);
|
|
|
|
|
|
|
|
|
|
const channelFollowings = await this.channelFollowingsRepository.find({
|
|
|
|
|
where: {
|
|
|
|
|
followeeId: note.channelId,
|
|
|
|
|
},
|
|
|
|
|
select: ['followerId'],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (const channelFollowing of channelFollowings) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimeline:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r);
|
|
|
|
|
if (note.fileIds.length > 0) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimelineWithFiles:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: キャッシュ?
|
|
|
|
|
// eslint-disable-next-line prefer-const
|
|
|
|
|
let [followings, userListMemberships] = await Promise.all([
|
|
|
|
@@ -886,22 +868,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|
|
|
|
userListMemberships = userListMemberships.filter(x => x.userListUserId === user.id || followings.some(f => f.followerId === x.userListUserId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
|
|
|
|
for (const following of followings) {
|
|
|
|
|
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
|
|
|
|
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
|
|
|
|
|
|
|
|
|
// 「自分自身への返信 or そのフォロワーへの返信」のどちらでもない場合
|
|
|
|
|
if (note.replyId && !(note.replyUserId === note.userId || note.replyUserId === following.followerId)) {
|
|
|
|
|
if (!following.withReplies) continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.funoutTimelineService.push(`homeTimeline:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r);
|
|
|
|
|
if (note.fileIds.length > 0) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimelineWithFiles:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const userListMembership of userListMemberships) {
|
|
|
|
|
// ダイレクトのとき、そのリストが対象外のユーザーの場合
|
|
|
|
|
if (
|
|
|
|
@@ -920,6 +886,41 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (note.channelId) {
|
|
|
|
|
this.funoutTimelineService.push(`channelTimeline:${note.channelId}`, note.id, this.config.perChannelMaxNoteCacheCount, r);
|
|
|
|
|
|
|
|
|
|
this.funoutTimelineService.push(`userTimelineWithChannel:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r);
|
|
|
|
|
|
|
|
|
|
const channelFollowings = await this.channelFollowingsRepository.find({
|
|
|
|
|
where: {
|
|
|
|
|
followeeId: note.channelId,
|
|
|
|
|
},
|
|
|
|
|
select: ['followerId'],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (const channelFollowing of channelFollowings) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimeline:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r);
|
|
|
|
|
if (note.fileIds.length > 0) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimelineWithFiles:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: あまりにも数が多いと redisPipeline.exec に失敗する(理由は不明)ため、3万件程度を目安に分割して実行するようにする
|
|
|
|
|
for (const following of followings) {
|
|
|
|
|
// 基本的にvisibleUserIdsには自身のidが含まれている前提であること
|
|
|
|
|
if (note.visibility === 'specified' && !note.visibleUserIds.some(v => v === following.followerId)) continue;
|
|
|
|
|
|
|
|
|
|
// 「自分自身への返信 or そのフォロワーへの返信」のどちらでもない場合
|
|
|
|
|
if (note.replyId && !(note.replyUserId === note.userId || note.replyUserId === following.followerId)) {
|
|
|
|
|
if (!following.withReplies) continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.funoutTimelineService.push(`homeTimeline:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r);
|
|
|
|
|
if (note.fileIds.length > 0) {
|
|
|
|
|
this.funoutTimelineService.push(`homeTimelineWithFiles:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (note.visibility !== 'specified' || !note.visibleUserIds.some(v => v === user.id)) { // 自分自身のHTL
|
|
|
|
|
this.funoutTimelineService.push(`homeTimeline:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax, r);
|
|
|
|
|
if (note.fileIds.length > 0) {
|
|
|
|
@@ -947,13 +948,13 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.random() < 0.1) {
|
|
|
|
|
process.nextTick(() => {
|
|
|
|
|
this.checkHibernation(followings);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.exec();
|
|
|
|
|
}
|
|
|
|
|