summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/users/notes.ts
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-05 02:34:57 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-05 02:34:57 -0400
commit05d7aa0b91525e9029b1e8a638561bf125ca32cb (patch)
treed4010119294e5ebfdd89d4c0b9543541a88d2bdd /packages/backend/src/server/api/endpoints/users/notes.ts
parentfix performance regression in mentions endpoint (diff)
downloadsharkey-05d7aa0b91525e9029b1e8a638561bf125ca32cb.tar.gz
sharkey-05d7aa0b91525e9029b1e8a638561bf125ca32cb.tar.bz2
sharkey-05d7aa0b91525e9029b1e8a638561bf125ca32cb.zip
additional fixes and cleanup to all note endpoints
Diffstat (limited to 'packages/backend/src/server/api/endpoints/users/notes.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/users/notes.ts26
1 files changed, 5 insertions, 21 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts
index 965baa859a..66b50e0633 100644
--- a/packages/backend/src/server/api/endpoints/users/notes.ts
+++ b/packages/backend/src/server/api/endpoints/users/notes.ts
@@ -205,7 +205,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('note.channel', 'channel')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .limit(ps.limit);
if (ps.withChannelNotes) {
if (!isSelf) query.andWhere(new Brackets(qb => {
@@ -230,26 +231,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (!ps.withRenotes && !ps.withQuotes) {
query.andWhere('note.renoteId IS NULL');
} else if (!ps.withRenotes) {
- query.andWhere(new Brackets(qb => {
- qb.orWhere('note.userId != :userId', { userId: ps.userId });
- 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)');
- }));
+ this.queryService.andIsNotRenote(query, 'note');
} else if (!ps.withQuotes) {
- query.andWhere(`
- (
- note."renoteId" IS NULL
- OR (
- note.text IS NULL
- AND note.cw IS NULL
- AND note."replyId" IS NULL
- AND note."hasPoll" IS FALSE
- AND note."fileIds" = '{}'
- )
- )
- `);
+ this.queryService.andIsNotQuote(query, 'note');
}
if (!ps.withRepliesToOthers && !ps.withRepliesToSelf) {
@@ -268,6 +252,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
query.andWhere('"user"."isBot" = false');
}
- return await query.limit(ps.limit).getMany();
+ return await query.getMany();
}
}