summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index 4514f3decd..097d657ba3 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -633,7 +633,7 @@ export class NoteCreateService implements OnApplicationShutdown {
}
if (this.isRenote(data) && !this.isQuote(data) && data.renote.userId !== user.id && !user.isBot) {
- this.incRenoteCount(data.renote);
+ this.incRenoteCount(data.renote, user);
}
if (data.poll && data.poll.expiresAt) {
@@ -816,8 +816,8 @@ export class NoteCreateService implements OnApplicationShutdown {
}
@bindThis
- private incRenoteCount(renote: MiNote) {
- this.notesRepository.createQueryBuilder().update()
+ private async incRenoteCount(renote: MiNote, user: MiUser) {
+ await this.notesRepository.createQueryBuilder().update()
.set({
renoteCount: () => '"renoteCount" + 1',
})
@@ -825,15 +825,18 @@ export class NoteCreateService implements OnApplicationShutdown {
.execute();
// 30%の確率、3日以内に投稿されたノートの場合ハイライト用ランキング更新
- if (Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) {
- if (renote.channelId != null) {
- if (renote.replyId == null) {
- this.featuredService.updateInChannelNotesRanking(renote.channelId, renote, 5);
- }
- } else {
- if (renote.visibility === 'public' && renote.userHost == null && renote.replyId == null) {
- this.featuredService.updateGlobalNotesRanking(renote, 5);
- this.featuredService.updatePerUserNotesRanking(renote.userId, renote, 5);
+ if (user.isExplorable && Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) {
+ const policies = await this.roleService.getUserPolicies(user);
+ if (policies.canTrend) {
+ if (renote.channelId != null) {
+ if (renote.replyId == null) {
+ this.featuredService.updateInChannelNotesRanking(renote.channelId, renote, 5);
+ }
+ } else {
+ if (renote.visibility === 'public' && renote.userHost == null && renote.replyId == null) {
+ this.featuredService.updateGlobalNotesRanking(renote, 5);
+ this.featuredService.updatePerUserNotesRanking(renote.userId, renote, 5);
+ }
}
}
}