fix: Comment deletion is not propagated correctly
This commit is contained in:
@@ -24,6 +24,8 @@ export default async function commentDestroyer({
|
|||||||
ip,
|
ip,
|
||||||
transaction,
|
transaction,
|
||||||
}: Props): Promise<Comment> {
|
}: Props): Promise<Comment> {
|
||||||
|
const document = await comment.$get("document", { transaction });
|
||||||
|
|
||||||
await comment.destroy({ transaction });
|
await comment.destroy({ transaction });
|
||||||
|
|
||||||
// Also destroy any child comments
|
// Also destroy any child comments
|
||||||
@@ -42,6 +44,7 @@ export default async function commentDestroyer({
|
|||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
actorId: user.id,
|
actorId: user.id,
|
||||||
documentId: comment.documentId,
|
documentId: comment.documentId,
|
||||||
|
collectionId: document?.collectionId,
|
||||||
ip,
|
ip,
|
||||||
},
|
},
|
||||||
{ transaction }
|
{ transaction }
|
||||||
|
|||||||
@@ -372,15 +372,8 @@ export default class WebsocketsProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "comments.delete": {
|
case "comments.delete": {
|
||||||
const comment = await Comment.scope([
|
|
||||||
"defaultScope",
|
|
||||||
"withDocument",
|
|
||||||
]).findByPk(event.modelId);
|
|
||||||
if (!comment) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return socketio
|
return socketio
|
||||||
.to(`collection-${comment.document.collectionId}`)
|
.to(`collection-${event.collectionId}`)
|
||||||
.emit(event.name, {
|
.emit(event.name, {
|
||||||
modelId: event.modelId,
|
modelId: event.modelId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -279,12 +279,20 @@ export type PinEvent = BaseEvent & {
|
|||||||
collectionId?: string;
|
collectionId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CommentEvent = BaseEvent & {
|
export type CommentEvent =
|
||||||
name: "comments.create" | "comments.update" | "comments.delete";
|
| (BaseEvent & {
|
||||||
modelId: string;
|
name: "comments.create" | "comments.update";
|
||||||
documentId: string;
|
modelId: string;
|
||||||
actorId: string;
|
documentId: string;
|
||||||
};
|
actorId: string;
|
||||||
|
})
|
||||||
|
| (BaseEvent & {
|
||||||
|
name: "comments.delete";
|
||||||
|
modelId: string;
|
||||||
|
documentId: string;
|
||||||
|
actorId: string;
|
||||||
|
collectionId: string;
|
||||||
|
});
|
||||||
|
|
||||||
export type StarEvent = BaseEvent & {
|
export type StarEvent = BaseEvent & {
|
||||||
name: "stars.create" | "stars.update" | "stars.delete";
|
name: "stars.create" | "stars.update" | "stars.delete";
|
||||||
|
|||||||
Reference in New Issue
Block a user