diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-08 14:30:29 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-09 11:41:22 +0100 |
commit | b49f22d8f9a52ab75fd38db2d377249eb58fa678 (patch) | |
tree | a2825877d7b3b53454804a79c9d2a14c5d37385c /server/lib/activitypub/video-rates.ts | |
parent | 6c8c15f914cd375da1db5d0cd4d924a86c53d4c1 (diff) | |
download | PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.gz PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.tar.zst PeerTube-b49f22d8f9a52ab75fd38db2d377249eb58fa678.zip |
Upgrade sequelize to v6
Diffstat (limited to 'server/lib/activitypub/video-rates.ts')
-rw-r--r-- | server/lib/activitypub/video-rates.ts | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index 581a2bca1..e246b1313 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts | |||
@@ -13,8 +13,6 @@ import { sendDislike } from './send/send-dislike' | |||
13 | import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../types/models' | 13 | import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../types/models' |
14 | 14 | ||
15 | async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { | 15 | async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { |
16 | let rateCounts = 0 | ||
17 | |||
18 | await Bluebird.map(ratesUrl, async rateUrl => { | 16 | await Bluebird.map(ratesUrl, async rateUrl => { |
19 | try { | 17 | try { |
20 | // Fetch url | 18 | // Fetch url |
@@ -43,21 +41,12 @@ async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateTy | |||
43 | url: body.id | 41 | url: body.id |
44 | } | 42 | } |
45 | 43 | ||
46 | const created = await AccountVideoRateModel.upsert(entry) | 44 | // Video "likes"/"dislikes" will be updated by the caller |
47 | 45 | await AccountVideoRateModel.upsert(entry) | |
48 | if (created) rateCounts += 1 | ||
49 | } catch (err) { | 46 | } catch (err) { |
50 | logger.warn('Cannot add rate %s.', rateUrl, { err }) | 47 | logger.warn('Cannot add rate %s.', rateUrl, { err }) |
51 | } | 48 | } |
52 | }, { concurrency: CRAWL_REQUEST_CONCURRENCY }) | 49 | }, { concurrency: CRAWL_REQUEST_CONCURRENCY }) |
53 | |||
54 | logger.info('Adding %d %s to video %s.', rateCounts, rate, video.uuid) | ||
55 | |||
56 | // This is "likes" and "dislikes" | ||
57 | if (rateCounts !== 0) { | ||
58 | const field = rate === 'like' ? 'likes' : 'dislikes' | ||
59 | await video.increment(field, { by: rateCounts }) | ||
60 | } | ||
61 | } | 50 | } |
62 | 51 | ||
63 | async function sendVideoRateChange ( | 52 | async function sendVideoRateChange ( |