1
0
Fork 0
peertube/server/lib/activitypub/send/send-dislike.ts

41 lines
1.3 KiB
TypeScript
Raw Normal View History

import { Transaction } from 'sequelize'
import { ActivityAudience, ActivityDislike } from '@shared/models'
import { logger } from '../../../helpers/logger'
2020-06-18 04:45:25 -04:00
import { MActor, MActorAudience, MVideoAccountLight, MVideoUrl } from '../../../types/models'
import { audiencify, getAudience } from '../audience'
import { getVideoDislikeActivityPubUrlByLocalActor } from '../url'
import { sendVideoActivityToOrigin } from './shared/send-utils'
2020-01-31 10:56:52 -05:00
function sendDislike (byActor: MActor, video: MVideoAccountLight, t: Transaction) {
logger.info('Creating job to dislike %s.', video.url)
const activityBuilder = (audience: ActivityAudience) => {
2020-11-20 05:21:08 -05:00
const url = getVideoDislikeActivityPubUrlByLocalActor(byActor, video)
return buildDislikeActivity(url, byActor, video, audience)
}
return sendVideoActivityToOrigin(activityBuilder, { byActor, video, transaction: t })
}
2019-08-15 05:53:26 -04:00
function buildDislikeActivity (url: string, byActor: MActorAudience, video: MVideoUrl, audience?: ActivityAudience): ActivityDislike {
if (!audience) audience = getAudience(byActor)
return audiencify(
{
id: url,
type: 'Dislike' as 'Dislike',
actor: byActor.url,
object: video.url
},
audience
)
}
// ---------------------------------------------------------------------------
export {
sendDislike,
buildDislikeActivity
}