import * as Sequelize from 'sequelize'
import { ResultList } from '../../shared/models'
import { VideoCommentThreadTree } from '../../shared/models/videos/video-comment.model'
-import { AccountModel } from '../models/account/account'
-import { VideoModel } from '../models/video/video'
import { VideoCommentModel } from '../models/video/video-comment'
import { getVideoCommentActivityPubUrl } from './activitypub'
import { sendCreateVideoComment } from './activitypub/send'
+import { MAccountDefault, MComment, MCommentOwnerVideoReply, MVideoFullLight } from '../typings/models'
async function createVideoComment (obj: {
- text: string,
- inReplyToComment: VideoCommentModel | null,
- video: VideoModel
- account: AccountModel
+ text: string
+ inReplyToComment: MComment | null
+ video: MVideoFullLight
+ account: MAccountDefault
}, t: Sequelize.Transaction) {
let originCommentId: number | null = null
let inReplyToCommentId: number | null = null
comment.url = getVideoCommentActivityPubUrl(obj.video, comment)
- const savedComment = await comment.save({ transaction: t })
+ const savedComment: MCommentOwnerVideoReply = await comment.save({ transaction: t })
savedComment.InReplyToVideoComment = obj.inReplyToComment
savedComment.Video = obj.video
savedComment.Account = obj.account
return thread
}
+function markCommentAsDeleted (comment: MCommentOwnerVideoReply): void {
+ comment.text = ''
+ comment.deletedAt = new Date()
+ comment.accountId = null
+}
+
// ---------------------------------------------------------------------------
export {
createVideoComment,
- buildFormattedCommentTree
+ buildFormattedCommentTree,
+ markCommentAsDeleted
}