aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-dislike.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-01 14:26:49 +0200
committerChocobozzz <me@florianbigard.com>2019-08-01 14:26:49 +0200
commita21e25ff641854c8b01664cb18655aa420620af6 (patch)
tree9caba3e48691564af8ef4f53dc200c4cf31f8152 /server/lib/activitypub/process/process-dislike.ts
parent29d4e1375fdac88595347184c3d1b214804794b0 (diff)
downloadPeerTube-a21e25ff641854c8b01664cb18655aa420620af6.tar.gz
PeerTube-a21e25ff641854c8b01664cb18655aa420620af6.tar.zst
PeerTube-a21e25ff641854c8b01664cb18655aa420620af6.zip
Fix like/dislike federation
Diffstat (limited to 'server/lib/activitypub/process/process-dislike.ts')
-rw-r--r--server/lib/activitypub/process/process-dislike.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/lib/activitypub/process/process-dislike.ts
index c46180617..f06269f8b 100644
--- a/server/lib/activitypub/process/process-dislike.ts
+++ b/server/lib/activitypub/process/process-dislike.ts
@@ -34,19 +34,20 @@ async function processDislike (activity: ActivityCreate | ActivityDislike, byAct
34 const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, url) 34 const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, url)
35 if (existingRate && existingRate.type === 'dislike') return 35 if (existingRate && existingRate.type === 'dislike') return
36 36
37 await AccountVideoRateModel.create({
38 type: 'dislike' as 'dislike',
39 videoId: video.id,
40 accountId: byAccount.id,
41 url
42 }, { transaction: t })
43
44 await video.increment('dislikes', { transaction: t }) 37 await video.increment('dislikes', { transaction: t })
45 38
46 if (existingRate && existingRate.type === 'like') { 39 if (existingRate && existingRate.type === 'like') {
47 await video.decrement('likes', { transaction: t }) 40 await video.decrement('likes', { transaction: t })
48 } 41 }
49 42
43 const rate = existingRate || new AccountVideoRateModel()
44 rate.type = 'dislike'
45 rate.videoId = video.id
46 rate.accountId = byAccount.id
47 rate.url = url
48
49 await rate.save({ transaction: t })
50
50 if (video.isOwned()) { 51 if (video.isOwned()) {
51 // Don't resend the activity to the sender 52 // Don't resend the activity to the sender
52 const exceptions = [ byActor ] 53 const exceptions = [ byActor ]