1 import { Transaction } from 'sequelize'
2 import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub'
3 import { getVideoLikeActivityPubUrl } from '../url'
4 import { sendVideoRelatedActivity } from './utils'
5 import { audiencify, getAudience } from '../audience'
6 import { logger } from '../../../helpers/logger'
7 import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../typings/models'
9 function sendLike (byActor: MActor, video: MVideoAccountLight, t: Transaction) {
10 logger.info('Creating job to like %s.', video.url)
12 const activityBuilder = (audience: ActivityAudience) => {
13 const url = getVideoLikeActivityPubUrl(byActor, video)
15 return buildLikeActivity(url, byActor, video, audience)
18 return sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction: t })
21 function buildLikeActivity (url: string, byActor: MActorAudience, video: MVideoUrl, audience?: ActivityAudience): ActivityLike {
22 if (!audience) audience = getAudience(byActor)
27 type: 'Like' as 'Like',
35 // ---------------------------------------------------------------------------