summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes/local-timeline.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/local-timeline.ts63
1 files changed, 36 insertions, 27 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
index f55853f3f3..41b1ee1086 100644
--- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
@@ -103,13 +103,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withBots: ps.withBots,
+ withRenotes: ps.withRenotes,
}, me);
- process.nextTick(() => {
- if (me) {
+ if (me) {
+ process.nextTick(() => {
this.activeUsersChart.read(me);
- }
- });
+ });
+ }
return await this.noteEntityService.packMany(timeline, me);
}
@@ -136,14 +137,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withBots: ps.withBots,
+ withRenotes: ps.withRenotes,
}, me),
});
- process.nextTick(() => {
- if (me) {
+ if (me) {
+ process.nextTick(() => {
this.activeUsersChart.read(me);
- }
- });
+ });
+ }
return timeline;
});
@@ -156,40 +158,47 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: boolean,
withReplies: boolean,
withBots: boolean,
+ withRenotes: boolean,
}, me: MiLocalUser | null) {
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
ps.sinceId, ps.untilId)
- .andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL) AND (note.channelId IS NULL)')
+ .andWhere('note.visibility = \'public\'')
+ .andWhere('note.channelId IS NULL')
+ .andWhere('note.userHost IS NULL')
.innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .limit(ps.limit);
+
+ if (!ps.withReplies) {
+ query
+ // 1. Not a reply, 2. a self-reply
+ .andWhere(new Brackets(qb => qb
+ .orWhere('note.replyId IS NULL') // 返信ではない
+ .orWhere('note.replyUserId = note.userId')));
+ }
- this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBlockedHostQueryForNote(query);
- if (me) this.queryService.generateMutedUserQueryForNotes(query, me);
- if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
- if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+ this.queryService.generateSilencedUserQueryForNotes(query, me);
+ if (me) {
+ this.queryService.generateMutedUserQueryForNotes(query, me);
+ this.queryService.generateBlockedUserQueryForNotes(query, me);
+ }
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
}
- if (!ps.withReplies) {
- query.andWhere(new Brackets(qb => {
- qb
- .where('note.replyId IS NULL') // 返信ではない
- .orWhere(new Brackets(qb => {
- qb // 返信だけど投稿者自身への返信
- .where('note.replyId IS NOT NULL')
- .andWhere('note.replyUserId = note.userId');
- }));
- }));
- }
-
if (!ps.withBots) query.andWhere('user.isBot = FALSE');
- return await query.limit(ps.limit).getMany();
+ if (!ps.withRenotes) {
+ this.queryService.generateExcludedRenotesQueryForNotes(query);
+ } else if (me) {
+ this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+ }
+
+ return await query.getMany();
}
}