aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/activitypub/process/process-dislike.ts15
-rw-r--r--server/lib/activitypub/process/process-like.ts19
2 files changed, 18 insertions, 16 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 ]
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index 5b2ab4b66..bba54a19b 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -34,19 +34,20 @@ async function processLikeVideo (byActor: ActorModel, activity: ActivityLike) {
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 === 'like') return 35 if (existingRate && existingRate.type === 'like') return
36 36
37 await AccountVideoRateModel.create({
38 type: 'like' as 'like',
39 videoId: video.id,
40 accountId: byAccount.id,
41 url
42 }, { transaction: t })
43
44 await video.increment('likes', { transaction: t })
45
46 if (existingRate && existingRate.type === 'dislike') { 37 if (existingRate && existingRate.type === 'dislike') {
47 await video.decrement('dislikes', { transaction: t }) 38 await video.decrement('dislikes', { transaction: t })
48 } 39 }
49 40
41 await video.increment('likes', { transaction: t })
42
43 const rate = existingRate || new AccountVideoRateModel()
44 rate.type = 'like'
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 ]