diff options
Diffstat (limited to 'server/lib/activitypub/video-rates.ts')
-rw-r--r-- | server/lib/activitypub/video-rates.ts | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index 7aac79118..ad7d81df6 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts | |||
@@ -38,19 +38,14 @@ async function createRates (ratesUrl: string[], video: VideoModel, rate: VideoRa | |||
38 | 38 | ||
39 | const actor = await getOrCreateActorAndServerAndModel(actorUrl) | 39 | const actor = await getOrCreateActorAndServerAndModel(actorUrl) |
40 | 40 | ||
41 | const [ , created ] = await AccountVideoRateModel | 41 | const entry = { |
42 | .findOrCreate({ | 42 | videoId: video.id, |
43 | where: { | 43 | accountId: actor.Account.id, |
44 | videoId: video.id, | 44 | type: rate, |
45 | accountId: actor.Account.id | 45 | url: body.id |
46 | }, | 46 | } |
47 | defaults: { | 47 | |
48 | videoId: video.id, | 48 | const created = await AccountVideoRateModel.upsert(entry) |
49 | accountId: actor.Account.id, | ||
50 | type: rate, | ||
51 | url: body.id | ||
52 | } | ||
53 | }) | ||
54 | 49 | ||
55 | if (created) rateCounts += 1 | 50 | if (created) rateCounts += 1 |
56 | } catch (err) { | 51 | } catch (err) { |