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 type { NotesRepository } from '@/models/_.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FanoutTimelineEndpointService {
|
export class FanoutTimelineEndpointService {
|
||||||
|
|
@ -22,7 +21,6 @@ export class FanoutTimelineEndpointService {
|
||||||
|
|
||||||
private noteEntityService: NoteEntityService,
|
private noteEntityService: NoteEntityService,
|
||||||
private fanoutTimelineService: FanoutTimelineService,
|
private fanoutTimelineService: FanoutTimelineService,
|
||||||
private metaService: MetaService,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,6 +30,7 @@ export class FanoutTimelineEndpointService {
|
||||||
sinceId: string | null,
|
sinceId: string | null,
|
||||||
limit: number,
|
limit: number,
|
||||||
me?: { id: MiUser['id'] } | undefined | null,
|
me?: { id: MiUser['id'] } | undefined | null,
|
||||||
|
useDbFallback: boolean,
|
||||||
redisTimelines: (string | { name: string, fallbackIfEmpty: boolean })[],
|
redisTimelines: (string | { name: string, fallbackIfEmpty: boolean })[],
|
||||||
noteFilter: (note: MiNote) => boolean,
|
noteFilter: (note: MiNote) => boolean,
|
||||||
dbFallback: (untilId: string | null, sinceId: string | null, limit: number) => Promise<MiNote[]>,
|
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);
|
const timeline = await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
|
||||||
|
|
||||||
return await this.noteEntityService.packMany(timeline, ps.me);
|
return await this.noteEntityService.packMany(timeline, ps.me);
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
sinceId,
|
sinceId,
|
||||||
limit: ps.limit,
|
limit: ps.limit,
|
||||||
me,
|
me,
|
||||||
|
useDbFallback: true,
|
||||||
redisTimelines: [`channelTimeline:${channel.id}`],
|
redisTimelines: [`channelTimeline:${channel.id}`],
|
||||||
noteFilter: note => {
|
noteFilter: note => {
|
||||||
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
|
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({
|
const redisTimeline = await this.fanoutTimelineEndpointService.timeline({
|
||||||
untilId, sinceId, limit: ps.limit,
|
untilId,
|
||||||
|
sinceId,
|
||||||
|
limit: ps.limit,
|
||||||
redisTimelines: timelineConfig,
|
redisTimelines: timelineConfig,
|
||||||
|
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||||
noteFilter: (note) => {
|
noteFilter: (note) => {
|
||||||
if (note.userId === me.id) {
|
if (note.userId === me.id) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
sinceId,
|
sinceId,
|
||||||
limit: ps.limit,
|
limit: ps.limit,
|
||||||
me,
|
me,
|
||||||
|
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||||
redisTimelines: ps.withFiles ? ['localTimelineWithFiles'] : ['localTimeline', 'localTimelineWithReplies'],
|
redisTimelines: ps.withFiles ? ['localTimelineWithFiles'] : ['localTimeline', 'localTimelineWithReplies'],
|
||||||
noteFilter: note => {
|
noteFilter: note => {
|
||||||
if (me && (note.userId === me.id)) {
|
if (me && (note.userId === me.id)) {
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
sinceId,
|
sinceId,
|
||||||
limit: ps.limit,
|
limit: ps.limit,
|
||||||
me,
|
me,
|
||||||
|
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||||
redisTimelines: ps.withFiles ? [`homeTimelineWithFiles:${me.id}`] : [`homeTimeline:${me.id}`],
|
redisTimelines: ps.withFiles ? [`homeTimelineWithFiles:${me.id}`] : [`homeTimeline:${me.id}`],
|
||||||
noteFilter: note => {
|
noteFilter: note => {
|
||||||
if (note.userId === me.id) {
|
if (note.userId === me.id) {
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
sinceId,
|
sinceId,
|
||||||
limit: ps.limit,
|
limit: ps.limit,
|
||||||
me,
|
me,
|
||||||
|
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
|
||||||
redisTimelines: ps.withFiles ? [`userListTimelineWithFiles:${list.id}`] : [`userListTimeline:${list.id}`],
|
redisTimelines: ps.withFiles ? [`userListTimelineWithFiles:${list.id}`] : [`userListTimeline:${list.id}`],
|
||||||
noteFilter: note => {
|
noteFilter: note => {
|
||||||
if (note.userId === me.id) {
|
if (note.userId === me.id) {
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
limit: ps.limit,
|
limit: ps.limit,
|
||||||
me,
|
me,
|
||||||
redisTimelines,
|
redisTimelines,
|
||||||
|
useDbFallback: true,
|
||||||
noteFilter: note => {
|
noteFilter: note => {
|
||||||
if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false;
|
if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue