mirror of
https://github.com/outline/outline.git
synced 2026-12-03 18:10:36 +03:00
handle reactions
This commit is contained in:
1 parent
ebb92cfa88
commit
ae4a7d7166
2 files changed
+6
-5
No files matched your search
@@ -18,10 +18,10 @@ import {
|
||||
Table,
|
||||
} from "sequelize-typescript";
|
||||
import { createContext } from "@server/context";
|
||||
import { APIContext } from "@server/types";
|
||||
import Comment from "./Comment";
|
||||
import User from "./User";
|
||||
import IdModel from "./base/IdModel";
|
||||
import { type HookContext } from "./base/Model";
|
||||
import Fix from "./decorators/Fix";
|
||||
import Length from "./validators/Length";
|
||||
|
||||
@@ -57,7 +57,7 @@ class Reaction extends IdModel<
|
||||
@AfterCreate
|
||||
public static async addReactionToCommentCache(
|
||||
model: Reaction,
|
||||
ctx: HookContext &
|
||||
ctx: APIContext["context"] &
|
||||
FindOrCreateOptions<Attributes<Reaction>, CreationAttributes<Reaction>>
|
||||
) {
|
||||
const { transaction } = ctx;
|
||||
@@ -109,7 +109,7 @@ class Reaction extends IdModel<
|
||||
@AfterDestroy
|
||||
public static async removeReactionFromCommentCache(
|
||||
model: Reaction,
|
||||
ctx: HookContext & InstanceDestroyOptions
|
||||
ctx: APIContext["context"] & InstanceDestroyOptions
|
||||
) {
|
||||
const { transaction } = ctx;
|
||||
|
||||
|
||||
@@ -375,12 +375,13 @@ router.post(
|
||||
authorize(user, "comment", document);
|
||||
authorize(user, "addReaction", comment);
|
||||
|
||||
await Reaction.findOrCreateWithCtx(ctx, {
|
||||
await Reaction.findOrCreate({
|
||||
where: {
|
||||
emoji,
|
||||
userId: user.id,
|
||||
commentId: id,
|
||||
},
|
||||
...ctx.context,
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
@@ -423,7 +424,7 @@ router.post(
|
||||
});
|
||||
authorize(user, "delete", reaction);
|
||||
|
||||
await reaction.destroyWithCtx(ctx);
|
||||
await reaction.destroy(ctx.context);
|
||||
|
||||
ctx.body = {
|
||||
success: true,
|
||||
|
||||
Reference in new issue
Block a user