aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorJulien Maulny <julien.maulny@protonmail.com>2019-12-03 21:48:31 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-12-04 09:36:45 +0100
commitb5206dfc455c119b0dcb897bd7144be6ea4d999d (patch)
treed79387081b80c0bbee38beee00f6560a599a99a9 /server/lib
parent69222afac8f8c41d90295b33f0695bbff352851e (diff)
downloadPeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.tar.gz
PeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.tar.zst
PeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.zip
Fix retrieving of deleted comments when subscribing to a new instance
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/video-comments.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 3e8306fa4..1a15842cf 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -131,9 +131,9 @@ async function resolveParentComment (params: ResolveThreadParams) {
131 } 131 }
132 132
133 const actorUrl = body.attributedTo 133 const actorUrl = body.attributedTo
134 if (!actorUrl) throw new Error('Miss attributed to in comment') 134 if (!actorUrl && body.type !== 'Tombstone') throw new Error('Miss attributed to in comment')
135 135
136 if (checkUrlsSameHost(url, actorUrl) !== true) { 136 if (actorUrl && checkUrlsSameHost(url, actorUrl) !== true) {
137 throw new Error(`Actor url ${actorUrl} has not the same host than the comment url ${url}`) 137 throw new Error(`Actor url ${actorUrl} has not the same host than the comment url ${url}`)
138 } 138 }
139 139
@@ -141,18 +141,19 @@ async function resolveParentComment (params: ResolveThreadParams) {
141 throw new Error(`Comment url ${url} host is different from the AP object id ${body.id}`) 141 throw new Error(`Comment url ${url} host is different from the AP object id ${body.id}`)
142 } 142 }
143 143
144 const actor = await getOrCreateActorAndServerAndModel(actorUrl, 'all') 144 const actor = actorUrl ? await getOrCreateActorAndServerAndModel(actorUrl, 'all') : null
145 const comment = new VideoCommentModel({ 145 const comment = new VideoCommentModel({
146 url: body.id, 146 url: body.id,
147 text: body.content, 147 text: body.content ? body.content : '',
148 videoId: null, 148 videoId: null,
149 accountId: actor.Account.id, 149 accountId: actor ? actor.Account.id : null,
150 inReplyToCommentId: null, 150 inReplyToCommentId: null,
151 originCommentId: null, 151 originCommentId: null,
152 createdAt: new Date(body.published), 152 createdAt: new Date(body.published),
153 updatedAt: new Date(body.updated) 153 updatedAt: new Date(body.updated),
154 deletedAt: body.deleted ? new Date(body.deleted) : null
154 }) as MCommentOwner 155 }) as MCommentOwner
155 comment.Account = actor.Account 156 comment.Account = actor ? actor.Account : null
156 157
157 return resolveThread({ 158 return resolveThread({
158 url: body.inReplyTo, 159 url: body.inReplyTo,