Merge branch 'no-ftt-test' into issue16270
This commit is contained in:
commit
f7f4cff66a
|
@ -20,6 +20,8 @@ import { CacheService } from '@/core/CacheService.js';
|
||||||
import { isReply } from '@/misc/is-reply.js';
|
import { isReply } from '@/misc/is-reply.js';
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||||
|
|
||||||
|
type NoteFilter = (note: MiNote) => boolean;
|
||||||
|
|
||||||
type TimelineOptions = {
|
type TimelineOptions = {
|
||||||
untilId: string | null,
|
untilId: string | null,
|
||||||
sinceId: string | null,
|
sinceId: string | null,
|
||||||
|
@ -28,7 +30,7 @@ type TimelineOptions = {
|
||||||
me?: { id: MiUser['id'] } | undefined | null,
|
me?: { id: MiUser['id'] } | undefined | null,
|
||||||
useDbFallback: boolean,
|
useDbFallback: boolean,
|
||||||
redisTimelines: FanoutTimelineName[],
|
redisTimelines: FanoutTimelineName[],
|
||||||
noteFilter?: (note: MiNote) => boolean,
|
noteFilter?: NoteFilter,
|
||||||
alwaysIncludeMyNotes?: boolean;
|
alwaysIncludeMyNotes?: boolean;
|
||||||
ignoreAuthorFromBlock?: boolean;
|
ignoreAuthorFromBlock?: boolean;
|
||||||
ignoreAuthorFromMute?: boolean;
|
ignoreAuthorFromMute?: boolean;
|
||||||
|
@ -79,7 +81,7 @@ export class FanoutTimelineEndpointService {
|
||||||
const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId;
|
const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId;
|
||||||
|
|
||||||
if (!shouldFallbackToDb) {
|
if (!shouldFallbackToDb) {
|
||||||
let filter = ps.noteFilter ?? (_note => true);
|
let filter = ps.noteFilter ?? (_note => true) as NoteFilter;
|
||||||
|
|
||||||
if (ps.alwaysIncludeMyNotes && ps.me) {
|
if (ps.alwaysIncludeMyNotes && ps.me) {
|
||||||
const me = ps.me;
|
const me = ps.me;
|
||||||
|
@ -145,15 +147,11 @@ export class FanoutTimelineEndpointService {
|
||||||
{
|
{
|
||||||
const parentFilter = filter;
|
const parentFilter = filter;
|
||||||
filter = (note) => {
|
filter = (note) => {
|
||||||
const noteJoined = note as MiNote & {
|
|
||||||
renoteUser: MiUser | null;
|
|
||||||
replyUser: MiUser | null;
|
|
||||||
};
|
|
||||||
if (!ps.ignoreAuthorFromUserSuspension) {
|
if (!ps.ignoreAuthorFromUserSuspension) {
|
||||||
if (note.user!.isSuspended) return false;
|
if (note.user!.isSuspended) return false;
|
||||||
}
|
}
|
||||||
if (note.userId !== note.renoteUserId && noteJoined.renoteUser?.isSuspended) return false;
|
if (note.userId !== note.renoteUserId && note.renote?.user?.isSuspended) return false;
|
||||||
if (note.userId !== note.replyUserId && noteJoined.replyUser?.isSuspended) return false;
|
if (note.userId !== note.replyUserId && note.reply?.user?.isSuspended) return false;
|
||||||
|
|
||||||
return parentFilter(note);
|
return parentFilter(note);
|
||||||
};
|
};
|
||||||
|
@ -200,7 +198,7 @@ export class FanoutTimelineEndpointService {
|
||||||
return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
|
return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getAndFilterFromDb(noteIds: string[], noteFilter: (note: MiNote) => boolean, idCompare: (a: string, b: string) => number): Promise<MiNote[]> {
|
private async getAndFilterFromDb(noteIds: string[], noteFilter: NoteFilter, idCompare: (a: string, b: string) => number): Promise<MiNote[]> {
|
||||||
const query = this.notesRepository.createQueryBuilder('note')
|
const query = this.notesRepository.createQueryBuilder('note')
|
||||||
.where('note.id IN (:...noteIds)', { noteIds: noteIds })
|
.where('note.id IN (:...noteIds)', { noteIds: noteIds })
|
||||||
.innerJoinAndSelect('note.user', 'user')
|
.innerJoinAndSelect('note.user', 'user')
|
||||||
|
|
Loading…
Reference in New Issue