diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-12-04 15:45:26 +0100 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-12-04 15:45:26 +0100 |
| commit | d5b598d69608e66dabae65216a6d90d3f0cbc0e1 (patch) | |
| tree | 5c66e8713a2e1c6972a94bbac540f51c4c686bc0 /packages/backend/src/server/api/endpoints/notes/edit.ts | |
| parent | fix: build error (diff) | |
| download | sharkey-d5b598d69608e66dabae65216a6d90d3f0cbc0e1.tar.gz sharkey-d5b598d69608e66dabae65216a6d90d3f0cbc0e1.tar.bz2 sharkey-d5b598d69608e66dabae65216a6d90d3f0cbc0e1.zip | |
fix: edit when it comes to quotes
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes/edit.ts')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/notes/edit.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index d5592c4726..cfbc207853 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -123,6 +123,18 @@ export const meta = { code: 'CANNOT_RENOTE_OUTSIDE_OF_CHANNEL', id: '33510210-8452-094c-6227-4a6c05d99f00', }, + + cannotQuoteaQuoteOfCurrentPost: { + message: 'Cannot quote a quote of edited note.', + code: 'CANNOT_QUOTE_A_QUOTE_OF_EDITED_NOTE', + id: '33510210-8452-094c-6227-4a6c05d99f01', + }, + + cannotQuoteCurrentPost: { + message: 'Cannot quote the current note.', + code: 'CANNOT_QUOTE_THE_CURRENT_NOTE', + id: '33510210-8452-094c-6227-4a6c05d99f02', + }, }, } as const; @@ -268,6 +280,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- } let renote: MiNote | null = null; + + if (ps.renoteId === ps.editId) { + throw new ApiError(meta.errors.cannotQuoteCurrentPost); + } + if (ps.renoteId != null) { // Fetch renote to note renote = await this.notesRepository.findOneBy({ id: ps.renoteId }); @@ -278,6 +295,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- throw new ApiError(meta.errors.cannotReRenote); } + if (renote.renoteId === ps.editId) { + throw new ApiError(meta.errors.cannotQuoteaQuoteOfCurrentPost); + } + // Check blocking if (renote.userId !== me.id) { const blockExist = await this.blockingsRepository.exist({ |