mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[mastodon-client] Fix error when liking the same status twice
This commit is contained in:
parent
6bf6a71151
commit
f36515a221
@ -28,6 +28,7 @@ import { toArray } from "@/prelude/array.js";
|
||||
import { MastoApiError } from "@/server/api/mastodon/middleware/catch-errors.js";
|
||||
import { Cache } from "@/misc/cache.js";
|
||||
import AsyncLock from "async-lock";
|
||||
import { IdentifiableError } from "@/misc/identifiable-error.js";
|
||||
|
||||
export class NoteHelpers {
|
||||
public static postIdempotencyCache = new Cache<{ status?: MastodonEntity.Status }>('postIdempotencyCache', 60 * 60);
|
||||
@ -45,7 +46,10 @@ export class NoteHelpers {
|
||||
}
|
||||
|
||||
public static async reactToNote(note: Note, user: ILocalUser, reaction: string): Promise<Note> {
|
||||
await createReaction(user, note, reaction);
|
||||
await createReaction(user, note, reaction).catch(e => {
|
||||
if (e instanceof IdentifiableError && e.id == '51c42bb4-931a-456b-bff7-e5a8a70dd298') return;
|
||||
throw e;
|
||||
});
|
||||
return getNote(note.id, user);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ export default async (
|
||||
await NoteReactions.insert(record);
|
||||
} else {
|
||||
// 同じリアクションがすでにされていたらエラー
|
||||
throw new IdentifiableError("51c42bb4-931a-456b-bff7-e5a8a70dd298");
|
||||
throw new IdentifiableError("51c42bb4-931a-456b-bff7-e5a8a70dd298", "Reaction already exists");
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
|
Loading…
Reference in New Issue
Block a user