From: Chocobozzz Date: Mon, 8 Jan 2018 12:15:01 +0000 (+0100) Subject: Fix comment creation X-Git-Tag: v0.0.1-alpha~34 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=378557ef2584e334392193b63bb2108fac6741fc;p=oweals%2Fpeertube.git Fix comment creation --- diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 32be37e2d..e65b257c0 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -283,7 +283,7 @@ function createVideoComment (byActor: ActorModel, activity: ActivityCreate) { const inReplyToComment = await VideoCommentModel.loadByUrl(comment.inReplyTo, t) if (!inReplyToComment) throw new Error('Unknown replied comment ' + comment.inReplyTo) - video = await VideoModel.load(inReplyToComment.videoId) + video = await VideoModel.loadAndPopulateAccount(inReplyToComment.videoId) const originCommentId = inReplyToComment.originCommentId || inReplyToComment.id objectToCreate = { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 4d15c2a50..918892938 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -507,6 +507,10 @@ export class VideoModel extends Model { return VideoModel.findById(id) } + static loadAndPopulateAccount (id: number) { + return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS ]).findById(id) + } + static loadByUrl (url: string, t?: Sequelize.Transaction) { const query: IFindOptions = { where: {