chore: add useDbFallback to FanoutTimelineEndpointService.timeline and always true for channel / user note list
This commit is contained in:
parent
d247134270
commit
d8c61488b5
|
|
@ -12,7 +12,6 @@ import { Packed } from '@/misc/json-schema.js';
|
|||
import type { NotesRepository } from '@/models/_.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
|
||||
@Injectable()
|
||||
export class FanoutTimelineEndpointService {
|
||||
|
|
@ -22,7 +21,6 @@ export class FanoutTimelineEndpointService {
|
|||
|
||||
private noteEntityService: NoteEntityService,
|
||||
private fanoutTimelineService: FanoutTimelineService,
|
||||
private metaService: MetaService,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +30,7 @@ export class FanoutTimelineEndpointService {
|
|||
sinceId: string | null,
|
||||
limit: number,
|
||||
me?: { id: MiUser['id'] } | undefined | null,
|
||||
useDbFallback: boolean,
|
||||
redisTimelines: (string | { name: string, fallbackIfEmpty: boolean })[],
|
||||
noteFilter: (note: MiNote) => boolean,
|
||||
dbFallback: (untilId: string | null, sinceId: string | null, limit: number) => Promise<MiNote[]>,
|
||||
|
|
@ -83,7 +82,7 @@ export class FanoutTimelineEndpointService {
|
|||
}
|
||||
}
|
||||
|
||||
if ((await this.metaService.fetch()).enableFanoutTimelineDbFallback) { // fallback to db
|
||||
if (ps.useDbFallback) { // fallback to db
|
||||
const timeline = await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
|
||||
|
||||
return await this.noteEntityService.packMany(timeline, ps.me);
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
sinceId,
|
||||
limit: ps.limit,
|
||||
me,
|
||||
useDbFallback: true,
|
||||
redisTimelines: [`channelTimeline:${channel.id}`],
|
||||
noteFilter: note => {
|
||||
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
||||
|
|
|
|||
|
|
@ -144,8 +144,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
|
||||
const redisTimeline = await this.fanoutTimelineEndpointService.timeline({
|
||||
untilId, sinceId, limit: ps.limit,
|
||||
untilId,
|
||||
sinceId,
|
||||
limit: ps.limit,
|
||||
redisTimelines: timelineConfig,
|
||||
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||
noteFilter: (note) => {
|
||||
if (note.userId === me.id) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
sinceId,
|
||||
limit: ps.limit,
|
||||
me,
|
||||
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||
redisTimelines: ps.withFiles ? ['localTimelineWithFiles'] : ['localTimeline', 'localTimelineWithReplies'],
|
||||
noteFilter: note => {
|
||||
if (me && (note.userId === me.id)) {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
sinceId,
|
||||
limit: ps.limit,
|
||||
me,
|
||||
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||
redisTimelines: ps.withFiles ? [`homeTimelineWithFiles:${me.id}`] : [`homeTimeline:${me.id}`],
|
||||
noteFilter: note => {
|
||||
if (note.userId === me.id) {
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
sinceId,
|
||||
limit: ps.limit,
|
||||
me,
|
||||
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||
redisTimelines: ps.withFiles ? [`userListTimelineWithFiles:${list.id}`] : [`userListTimeline:${list.id}`],
|
||||
noteFilter: note => {
|
||||
if (note.userId === me.id) {
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
limit: ps.limit,
|
||||
me,
|
||||
redisTimelines,
|
||||
useDbFallback: true,
|
||||
noteFilter: note => {
|
||||
if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue