mirror of
https://github.com/wassname/talk.git
synced 2026-07-20 12:40:47 +08:00
fix: remove assetID from EditCommentInput
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user