import { Transaction } from 'sequelize' ; import { ActivityAudience , ActivityLike } from '../../../../shared/models/activitypub' ; import { getVideoLikeActivityPubUrlByLocalActor } from '../url' ; import { sendVideoRelatedActivity } from './utils' ; import { audiencify , getAudience } from '../audience' ; import { logger } from '../../../helpers/logger' ; import { MActor , MActorAudience , MVideoAccountLight , MVideoUrl } from '../../../types/models' ; function sendLike ( byActor , video , t ) { logger . info ( 'Creating job to like %s.' , video . url ) ; const activityBuilder = ( audience ) => { const url = getVideoLikeActivityPubUrlByLocalActor ( byActor , video ) ; return buildLikeActivity ( url , byActor , video , audience ) ; } ; return sendVideoRelatedActivity ( activityBuilder , { byActor , video , transaction : t } ) ; } function buildLikeActivity ( url , byActor , video , audience ? ) { if ( ! audience ) audience = getAudience ( byActor ) ; return audiencify ( { id : url , type : 'Like' as 'Like' , actor : byActor . url , object : video . url } , audience ) ; } export { sendLike , buildLikeActivity } ;