Improve error handling of API (#4345)
* wip
* wip
* wip
* Update attached_notes.ts
* wip
* Refactor
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update call.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* ✌️
* Fix
This commit is contained in:
parent
fc52e95ad0
commit
2756f553c6
181 changed files with 2010 additions and 1322 deletions
|
|
@ -6,8 +6,9 @@ import renderLike from '../../../remote/activitypub/renderer/like';
|
|||
import renderUndo from '../../../remote/activitypub/renderer/undo';
|
||||
import { renderActivity } from '../../../remote/activitypub/renderer';
|
||||
import { deliver } from '../../../queue';
|
||||
import { IdentifiableError } from '../../../misc/identifiable-error';
|
||||
|
||||
export default async (user: IUser, note: INote) => new Promise(async (res, rej) => {
|
||||
export default async (user: IUser, note: INote) => {
|
||||
// if already unreacted
|
||||
const exist = await Reaction.findOne({
|
||||
noteId: note._id,
|
||||
|
|
@ -16,7 +17,7 @@ export default async (user: IUser, note: INote) => new Promise(async (res, rej)
|
|||
});
|
||||
|
||||
if (exist === null) {
|
||||
return rej('never reacted');
|
||||
throw new IdentifiableError('60527ec9-b4cb-4a88-a6bd-32d3ad26817d', 'not reacted');
|
||||
}
|
||||
|
||||
// Delete reaction
|
||||
|
|
@ -24,8 +25,6 @@ export default async (user: IUser, note: INote) => new Promise(async (res, rej)
|
|||
_id: exist._id
|
||||
});
|
||||
|
||||
res();
|
||||
|
||||
const dec: any = {};
|
||||
dec[`reactionCounts.${exist.reaction}`] = -1;
|
||||
|
||||
|
|
@ -46,4 +45,6 @@ export default async (user: IUser, note: INote) => new Promise(async (res, rej)
|
|||
deliver(user, content, note._user.inbox);
|
||||
}
|
||||
//#endregion
|
||||
});
|
||||
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue