upd: Separate quote from boost

This commit is contained in:
Mar0xy 2023-10-15 02:16:02 +02:00
parent 4359a13946
commit 7e648a255f
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
7 changed files with 413 additions and 206 deletions

View file

@ -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<typeof meta, typeof paramDef> { // 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')

View file

@ -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<typeof meta, typeof paramDef> { // 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);

View file

@ -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<typeof meta, typeof paramDef> { // 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);
}
}
});
}