Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import deleteReaction from "../../../../../services/note/reaction/delete.js";
|
||||
import define from "../../../define.js";
|
||||
import { getNote } from "../../../common/getters.js";
|
||||
import { ApiError } from "../../../error.js";
|
||||
import { SECOND, HOUR } from "../../../../../const.js";
|
||||
import { getGroupActor } from "../../../common/get-group-actor.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"reactions",
|
||||
"notes"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "write:reactions",
|
||||
limit: {
|
||||
duration: HOUR,
|
||||
max: 60,
|
||||
minInterval: 3 * SECOND
|
||||
},
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: "No such note.",
|
||||
code: "NO_SUCH_NOTE",
|
||||
id: "764d9fce-f9f2-4a0e-92b1-6ceac9a7ad37"
|
||||
},
|
||||
notReacted: {
|
||||
message: "You are not reacting to that note.",
|
||||
code: "NOT_REACTED",
|
||||
id: "92f4426d-4196-4125-aa5b-02943e2ec8fc"
|
||||
},
|
||||
noSuchGroup: {
|
||||
message: "No such group.",
|
||||
code: "NO_SUCH_GROUP",
|
||||
id: "04a4f3d8-773e-43e4-a645-71da6bb03a6f"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
noteId: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
},
|
||||
groupId: {
|
||||
type: "string",
|
||||
format: "misskey:id",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"noteId"
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const note = await getNote(ps.noteId, user).catch((err)=>{
|
||||
if (err.id === "9725d0ce-ba28-4dde-95a7-2cbb2c15de24") throw new ApiError(meta.errors.noSuchNote);
|
||||
throw err;
|
||||
});
|
||||
const group = await getGroupActor(ps.groupId, user);
|
||||
if (ps.groupId != null && group == null) throw new ApiError(meta.errors.noSuchGroup);
|
||||
await deleteReaction({
|
||||
...user,
|
||||
groupId: group?.id ?? null
|
||||
}, note).catch((e)=>{
|
||||
if (e.id === "60527ec9-b4cb-4a88-a6bd-32d3ad26817d") throw new ApiError(meta.errors.notReacted);
|
||||
throw e;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user