-import { getVideoCommentActivityPubUrl } from './activitypub'
-import { sendCreateVideoComment } from './activitypub/send'
+import { MAccountDefault, MComment, MCommentOwnerVideo, MCommentOwnerVideoReply, MVideoFullLight } from '../types/models'
+import { sendCreateVideoComment, sendDeleteVideoComment } from './activitypub/send'
+import { getLocalVideoCommentActivityPubUrl } from './activitypub/url'
+import { Hooks } from './plugins/hooks'
+
+async function removeComment (videoCommentInstance: MCommentOwnerVideo) {
+ const videoCommentInstanceBefore = cloneDeep(videoCommentInstance)
+
+ await sequelizeTypescript.transaction(async t => {
+ if (videoCommentInstance.isOwned() || videoCommentInstance.Video.isOwned()) {
+ await sendDeleteVideoComment(videoCommentInstance, t)
+ }
+
+ markCommentAsDeleted(videoCommentInstance)
+
+ await videoCommentInstance.save()
+ })
+
+ logger.info('Video comment %d deleted.', videoCommentInstance.id)
+
+ Hooks.runAction('action:api.video-comment.deleted', { comment: videoCommentInstanceBefore })
+}