- const videoChannel: VideoChannelModel = await processCreateActivity(announcedActivity)
- const share = {
- accountId: accountAnnouncer.id,
- videoChannelId: videoChannel.id
- }
-
- const [ , created ] = await VideoChannelShareModel.findOrCreate({
- where: share,
- defaults: share,
- transaction: t
- })
-
- if (videoChannel.isOwned() && created === true) {
- // Don't resend the activity to the sender
- const exceptions = [ accountAnnouncer ]
- await forwardActivity(activity, t, exceptions)
- }
-
- return undefined
- })
-}
-
-function processVideoShare (accountAnnouncer: AccountModel, activity: ActivityAnnounce) {
- const options = {
- arguments: [ accountAnnouncer, activity ],
- errorMessage: 'Cannot share the video with many retries.'
- }
-
- return retryTransactionWrapper(shareVideo, options)
-}
-
-function shareVideo (accountAnnouncer: AccountModel, activity: ActivityAnnounce) {
- const announcedActivity = activity.object as ActivityAdd
-
- return sequelizeTypescript.transaction(async t => {
- // Add share entry
- const video: VideoModel = await processAddActivity(announcedActivity)