From 7e648a255f03a6ba0ebeb8547509796f3a9bd7d2 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 15 Oct 2023 02:16:02 +0200 Subject: upd: Separate quote from boost --- .../src/server/api/endpoints/notes/children.ts | 25 ++++++++++++---------- .../src/server/api/endpoints/notes/renotes.ts | 9 +++++++- .../src/server/api/endpoints/notes/unrenote.ts | 7 +++++- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'packages/backend/src/server/api') diff --git a/packages/backend/src/server/api/endpoints/notes/children.ts b/packages/backend/src/server/api/endpoints/notes/children.ts index 1e569d9806..a16740c816 100644 --- a/packages/backend/src/server/api/endpoints/notes/children.ts +++ b/packages/backend/src/server/api/endpoints/notes/children.ts @@ -34,6 +34,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, + showQuotes: { type: 'boolean', default: true }, }, required: ['noteId'], } as const; @@ -51,17 +52,19 @@ export default class extends Endpoint { // eslint- const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) .andWhere(new Brackets(qb => { qb - .where('note.replyId = :noteId', { noteId: ps.noteId }) - .orWhere(new Brackets(qb => { - qb - .where('note.renoteId = :noteId', { noteId: ps.noteId }) - .andWhere(new Brackets(qb => { - qb - .where('note.text IS NOT NULL') - .orWhere('note.fileIds != \'{}\'') - .orWhere('note.hasPoll = TRUE'); - })); - })); + .where('note.replyId = :noteId', { noteId: ps.noteId }); + if (ps.showQuotes) { + qb.orWhere(new Brackets(qb => { + qb + .where('note.renoteId = :noteId', { noteId: ps.noteId }) + .andWhere(new Brackets(qb => { + qb + .where('note.text IS NOT NULL') + .orWhere('note.fileIds != \'{}\'') + .orWhere('note.hasPoll = TRUE'); + })); + })); + } })) .innerJoinAndSelect('note.user', 'user') .leftJoinAndSelect('note.reply', 'reply') diff --git a/packages/backend/src/server/api/endpoints/notes/renotes.ts b/packages/backend/src/server/api/endpoints/notes/renotes.ts index 2099701ab2..063650b3c7 100644 --- a/packages/backend/src/server/api/endpoints/notes/renotes.ts +++ b/packages/backend/src/server/api/endpoints/notes/renotes.ts @@ -44,6 +44,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, + quote: { type: 'boolean', default: false }, }, required: ['noteId'], } as const; @@ -74,7 +75,13 @@ export default class extends Endpoint { // eslint- if (ps.userId) { query.andWhere("user.id = :userId", { userId: ps.userId }); - } + } + + if (ps.quote) { + query.andWhere("note.text IS NOT NULL"); + } else { + query.andWhere("note.text IS NULL"); + } this.queryService.generateVisibilityQuery(query, me); if (me) this.queryService.generateMutedUserQuery(query, me); diff --git a/packages/backend/src/server/api/endpoints/notes/unrenote.ts b/packages/backend/src/server/api/endpoints/notes/unrenote.ts index 1b71de4966..249344a6f3 100644 --- a/packages/backend/src/server/api/endpoints/notes/unrenote.ts +++ b/packages/backend/src/server/api/endpoints/notes/unrenote.ts @@ -38,6 +38,7 @@ export const paramDef = { type: 'object', properties: { noteId: { type: 'string', format: 'misskey:id' }, + quote: { type: 'boolean', default: false }, }, required: ['noteId'], } as const; @@ -66,7 +67,11 @@ export default class extends Endpoint { // eslint- }); for (const note of renotes) { - this.noteDeleteService.delete(await this.usersRepository.findOneByOrFail({ id: me.id }), note, false); + if (ps.quote) { + if (note.text) this.noteDeleteService.delete(await this.usersRepository.findOneByOrFail({ id: me.id }), note, false); + } else { + if (!note.text) this.noteDeleteService.delete(await this.usersRepository.findOneByOrFail({ id: me.id }), note, false); + } } }); } -- cgit v1.2.3-freya