fix: remove assetID from EditCommentInput

This commit is contained in:
Wyatt Johnson
2018-09-11 16:35:00 -06:00
parent cf070ddb0f
commit a794fe8cd7
3 changed files with 10 additions and 14 deletions
@@ -26,7 +26,6 @@ export default (ctx: TenantContext) => ({
ctx.user!,
{
id: input.commentID,
asset_id: input.assetID,
body: input.body,
},
ctx.req
@@ -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.
"""
+10 -8
View File
@@ -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,