mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
don't trend notes from non-explorable or non-trendable users
This commit is contained in:
parent
0b8c101d71
commit
dee2e19b63
3 changed files with 33 additions and 21 deletions
|
@ -633,7 +633,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isRenote(data) && !this.isQuote(data) && data.renote.userId !== user.id && !user.isBot) {
|
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) {
|
if (data.poll && data.poll.expiresAt) {
|
||||||
|
@ -816,8 +816,8 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private incRenoteCount(renote: MiNote) {
|
private async incRenoteCount(renote: MiNote, user: MiUser) {
|
||||||
this.notesRepository.createQueryBuilder().update()
|
await this.notesRepository.createQueryBuilder().update()
|
||||||
.set({
|
.set({
|
||||||
renoteCount: () => '"renoteCount" + 1',
|
renoteCount: () => '"renoteCount" + 1',
|
||||||
})
|
})
|
||||||
|
@ -825,15 +825,18 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
// 30%の確率、3日以内に投稿されたノートの場合ハイライト用ランキング更新
|
// 30%の確率、3日以内に投稿されたノートの場合ハイライト用ランキング更新
|
||||||
if (Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) {
|
if (user.isExplorable && Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) {
|
||||||
if (renote.channelId != null) {
|
const policies = await this.roleService.getUserPolicies(user);
|
||||||
if (renote.replyId == null) {
|
if (policies.canTrend) {
|
||||||
this.featuredService.updateInChannelNotesRanking(renote.channelId, renote, 5);
|
if (renote.channelId != null) {
|
||||||
}
|
if (renote.replyId == null) {
|
||||||
} else {
|
this.featuredService.updateInChannelNotesRanking(renote.channelId, renote, 5);
|
||||||
if (renote.visibility === 'public' && renote.userHost == null && renote.replyId == null) {
|
}
|
||||||
this.featuredService.updateGlobalNotesRanking(renote, 5);
|
} else {
|
||||||
this.featuredService.updatePerUserNotesRanking(renote.userId, renote, 5);
|
if (renote.visibility === 'public' && renote.userHost == null && renote.replyId == null) {
|
||||||
|
this.featuredService.updateGlobalNotesRanking(renote, 5);
|
||||||
|
this.featuredService.updatePerUserNotesRanking(renote.userId, renote, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { trackPromise } from '@/misc/promise-tracker.js';
|
||||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js';
|
||||||
import { PER_NOTE_REACTION_USER_PAIR_CACHE_MAX } from '@/const.js';
|
import { PER_NOTE_REACTION_USER_PAIR_CACHE_MAX } from '@/const.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
|
||||||
const FALLBACK = '\u2764';
|
const FALLBACK = '\u2764';
|
||||||
|
|
||||||
|
@ -102,6 +103,7 @@ export class ReactionService {
|
||||||
private apDeliverManagerService: ApDeliverManagerService,
|
private apDeliverManagerService: ApDeliverManagerService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private perUserReactionsChart: PerUserReactionsChart,
|
private perUserReactionsChart: PerUserReactionsChart,
|
||||||
|
private readonly cacheService: CacheService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,14 +222,20 @@ export class ReactionService {
|
||||||
note.userId !== user.id &&
|
note.userId !== user.id &&
|
||||||
(Date.now() - this.idService.parse(note.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3
|
(Date.now() - this.idService.parse(note.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3
|
||||||
) {
|
) {
|
||||||
if (note.channelId != null) {
|
const author = await this.cacheService.findUserById(note.userId);
|
||||||
if (note.replyId == null) {
|
if (author.isExplorable) {
|
||||||
this.featuredService.updateInChannelNotesRanking(note.channelId, note, 1);
|
const policies = await this.roleService.getUserPolicies(author);
|
||||||
}
|
if (policies.canTrend) {
|
||||||
} else {
|
if (note.channelId != null) {
|
||||||
if (note.visibility === 'public' && note.userHost == null && note.replyId == null) {
|
if (note.replyId == null) {
|
||||||
this.featuredService.updateGlobalNotesRanking(note, 1);
|
this.featuredService.updateInChannelNotesRanking(note.channelId, note, 1);
|
||||||
this.featuredService.updatePerUserNotesRanking(note.userId, note, 1);
|
}
|
||||||
|
} else {
|
||||||
|
if (note.visibility === 'public' && note.userHost == null && note.replyId == null) {
|
||||||
|
this.featuredService.updateGlobalNotesRanking(note, 1);
|
||||||
|
this.featuredService.updatePerUserNotesRanking(note.userId, note, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
.leftJoinAndSelect('note.renote', 'renote')
|
.leftJoinAndSelect('note.renote', 'renote')
|
||||||
.leftJoinAndSelect('reply.user', 'replyUser')
|
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||||
.leftJoinAndSelect('note.channel', 'channel');
|
.leftJoinAndSelect('note.channel', 'channel')
|
||||||
|
.andWhere('user.isExplorable = TRUE');
|
||||||
|
|
||||||
this.queryService.generateBlockedHostQueryForNote(query);
|
this.queryService.generateBlockedHostQueryForNote(query);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue