summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-03 15:26:46 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-03 15:29:42 -0400
commitef3b5541f8ca090141bed371fc39480af8ea874b (patch)
treeafacd6daf85b49bbd2547758016c49d55b549481 /packages/backend/src/server/api/endpoints/notes
parentcopy changes to local-timeline.ts (diff)
downloadsharkey-ef3b5541f8ca090141bed371fc39480af8ea874b.tar.gz
sharkey-ef3b5541f8ca090141bed371fc39480af8ea874b.tar.bz2
sharkey-ef3b5541f8ca090141bed371fc39480af8ea874b.zip
copy changes to hybrid-timeline.ts
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts57
1 files changed, 12 insertions, 45 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
index 6461a2e33f..083da9090f 100644
--- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
@@ -66,9 +66,6 @@ export const paramDef = {
sinceDate: { type: 'integer' },
untilDate: { type: 'integer' },
allowPartial: { type: 'boolean', default: false }, // true is recommended but for compatibility false by default
- includeMyRenotes: { type: 'boolean', default: true },
- includeRenotedMyNotes: { type: 'boolean', default: true },
- includeLocalRenotes: { type: 'boolean', default: true },
withFiles: { type: 'boolean', default: false },
withRenotes: { type: 'boolean', default: true },
withReplies: { type: 'boolean', default: false },
@@ -114,12 +111,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
untilId,
sinceId,
limit: ps.limit,
- includeMyRenotes: ps.includeMyRenotes,
- includeRenotedMyNotes: ps.includeRenotedMyNotes,
- includeLocalRenotes: ps.includeLocalRenotes,
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withBots: ps.withBots,
+ withRenotes: ps.withRenotes,
}, me);
process.nextTick(() => {
@@ -178,12 +173,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
untilId,
sinceId,
limit,
- includeMyRenotes: ps.includeMyRenotes,
- includeRenotedMyNotes: ps.includeRenotedMyNotes,
- includeLocalRenotes: ps.includeLocalRenotes,
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withBots: ps.withBots,
+ withRenotes: ps.withRenotes,
}, me),
});
@@ -199,12 +192,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
untilId: string | null,
sinceId: string | null,
limit: number,
- includeMyRenotes: boolean,
- includeRenotedMyNotes: boolean,
- includeLocalRenotes: boolean,
withFiles: boolean,
withReplies: boolean,
withBots: boolean,
+ withRenotes: boolean,
}, me: MiLocalUser) {
const followees = await this.userFollowingService.getFollowees(me.id);
const followingChannels = await this.channelFollowingsRepository.find({
@@ -227,8 +218,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
- .leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('reply.user', 'replyUser', 'replyUser.id = note.replyUserId')
+ .leftJoinAndSelect('renote.user', 'renoteUser', 'renoteUser.id = note.renoteUserId');
if (followingChannels.length > 0) {
const followingChannelIds = followingChannels.map(x => x.followeeId);
@@ -255,45 +246,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBlockedHostQueryForNote(query);
+ this.queryService.generateSilencedUserQueryForNotes(query, me);
this.queryService.generateMutedUserQueryForNotes(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
- this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
-
- if (ps.includeMyRenotes === false) {
- query.andWhere(new Brackets(qb => {
- qb.orWhere('note.userId != :meId', { meId: me.id });
- qb.orWhere('note.renoteId IS NULL');
- qb.orWhere('note.text IS NOT NULL');
- qb.orWhere('note.fileIds != \'{}\'');
- qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
- }));
- }
-
- if (ps.includeRenotedMyNotes === false) {
- query.andWhere(new Brackets(qb => {
- qb.orWhere('note.renoteUserId != :meId', { meId: me.id });
- qb.orWhere('note.renoteId IS NULL');
- qb.orWhere('note.text IS NOT NULL');
- qb.orWhere('note.fileIds != \'{}\'');
- qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
- }));
- }
-
- if (ps.includeLocalRenotes === false) {
- query.andWhere(new Brackets(qb => {
- qb.orWhere('note.renoteUserHost IS NOT NULL');
- qb.orWhere('note.renoteId IS NULL');
- qb.orWhere('note.text IS NOT NULL');
- qb.orWhere('note.fileIds != \'{}\'');
- qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)');
- }));
- }
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
}
if (!ps.withBots) query.andWhere('user.isBot = FALSE');
+
+ if (!ps.withRenotes) {
+ this.queryService.generateExcludedRenotesQueryForNotes(query);
+ } else {
+ this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
+ }
//#endregion
return await query.limit(ps.limit).getMany();