2017-11-20 02:43:39 -06:00
|
|
|
import { Transaction } from 'sequelize'
|
|
|
|
import { ActivityCreate } from '../../../../shared/models/activitypub/activity'
|
|
|
|
import { AccountInstance, VideoChannelInstance, VideoInstance } from '../../../models'
|
|
|
|
import { VideoAbuseInstance } from '../../../models/video/video-abuse-interface'
|
|
|
|
import { broadcastToFollowers, getAudience, unicastTo } from './misc'
|
2017-11-20 03:24:29 -06:00
|
|
|
import { getVideoAbuseActivityPubUrl } from '../url'
|
2017-11-20 02:43:39 -06:00
|
|
|
|
|
|
|
async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Transaction) {
|
|
|
|
const byAccount = videoChannel.Account
|
|
|
|
|
|
|
|
const videoChannelObject = videoChannel.toActivityPubObject()
|
|
|
|
const data = await createActivityData(videoChannel.url, byAccount, videoChannelObject)
|
|
|
|
|
|
|
|
return broadcastToFollowers(data, byAccount, [ byAccount ], t)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function sendVideoAbuse (byAccount: AccountInstance, videoAbuse: VideoAbuseInstance, video: VideoInstance, t: Transaction) {
|
|
|
|
const url = getVideoAbuseActivityPubUrl(videoAbuse)
|
|
|
|
const data = await createActivityData(url, byAccount, videoAbuse.toActivityPubObject())
|
|
|
|
|
|
|
|
return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
|
|
|
|
}
|
|
|
|
|
2017-11-22 03:29:55 -06:00
|
|
|
// async function sendCreateView ()
|
|
|
|
|
2017-11-20 02:43:39 -06:00
|
|
|
async function createActivityData (url: string, byAccount: AccountInstance, object: any) {
|
|
|
|
const { to, cc } = await getAudience(byAccount)
|
|
|
|
const activity: ActivityCreate = {
|
|
|
|
type: 'Create',
|
|
|
|
id: url,
|
|
|
|
actor: byAccount.url,
|
|
|
|
to,
|
|
|
|
cc,
|
|
|
|
object
|
|
|
|
}
|
|
|
|
|
|
|
|
return activity
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
sendCreateVideoChannel,
|
|
|
|
sendVideoAbuse,
|
|
|
|
createActivityData
|
|
|
|
}
|