diff --git a/src/core/server/graph/tenant/mutators/comment.ts b/src/core/server/graph/tenant/mutators/comment.ts index d0c26e431..aeaac70ee 100644 --- a/src/core/server/graph/tenant/mutators/comment.ts +++ b/src/core/server/graph/tenant/mutators/comment.ts @@ -26,7 +26,6 @@ export default (ctx: TenantContext) => ({ ctx.user!, { id: input.commentID, - asset_id: input.assetID, body: input.body, }, ctx.req diff --git a/src/core/server/graph/tenant/schema/schema.graphql b/src/core/server/graph/tenant/schema/schema.graphql index dc689f403..1ba2546d6 100644 --- a/src/core/server/graph/tenant/schema/schema.graphql +++ b/src/core/server/graph/tenant/schema/schema.graphql @@ -879,11 +879,6 @@ type CreateCommentPayload { EditCommentInput provides the input for the editComment Mutation. """ input EditCommentInput { - """ - assetID is the ID of the Asset where we are editing a comment on. - """ - assetID: ID! - """ commentID is the ID of the comment being edited. """ diff --git a/src/core/server/services/comments/index.ts b/src/core/server/services/comments/index.ts index b356b919b..91e124216 100644 --- a/src/core/server/services/comments/index.ts +++ b/src/core/server/services/comments/index.ts @@ -74,12 +74,7 @@ export async function create( export type EditComment = Omit< EditCommentInput, "status" | "author_id" | "lastEditableCommentCreatedAt" -> & { - /** - * asset_id is the asset that the comment exists on. - */ - asset_id: string; -}; +>; export async function edit( mongo: Db, @@ -88,8 +83,15 @@ export async function edit( input: EditComment, req?: Request ) { + // Get the comment that we're editing. + let comment = await retrieveComment(mongo, tenant.id, input.id); + if (!comment) { + // TODO: replace to match error returned by the models/comments.ts + throw new Error("comment not found"); + } + // Grab the asset that we'll use to check moderation pieces with. - const asset = await retrieveAsset(mongo, tenant.id, input.asset_id); + const asset = await retrieveAsset(mongo, tenant.id, comment.asset_id); if (!asset) { // TODO: (wyattjoh) return better error. throw new Error("asset referenced does not exist"); @@ -106,7 +108,7 @@ export async function edit( // TODO: (wyattjoh) use the actions somehow. - const comment = await editComment(mongo, tenant.id, { + comment = await editComment(mongo, tenant.id, { id: input.id, author_id: author.id, body: input.body,