+
+// ---------------------------------------------------------------------------
+
+async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) {
+ const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
+
+ const { video } = await getOrCreateAccountAndVideoAndChannel(objectUri)
+
+ return sequelizeTypescript.transaction(async t => {
+ // Add share entry
+
+ const share = {
+ actorId: actorAnnouncer.id,
+ videoId: video.id,
+ url: activity.id
+ }
+
+ const [ , created ] = await VideoShareModel.findOrCreate({
+ where: {
+ url: activity.id
+ },
+ defaults: share,
+ transaction: t
+ })
+
+ if (video.isOwned() && created === true) {
+ // Don't resend the activity to the sender
+ const exceptions = [ actorAnnouncer ]
+
+ await forwardVideoRelatedActivity(activity, t, exceptions, video)
+ }
+
+ return undefined
+ })
+}