+async function addVideoShare (shareUrl: string, video: MVideoId) {
+ const { body } = await doJSONRequest<any>(shareUrl, { activityPub: true })
+ if (!body || !body.actor) throw new Error('Body or body actor is invalid')
+
+ const actorUrl = getAPId(body.actor)
+ if (checkUrlsSameHost(shareUrl, actorUrl) !== true) {
+ throw new Error(`Actor url ${actorUrl} has not the same host than the share url ${shareUrl}`)
+ }
+
+ const actor = await getOrCreateAPActor(actorUrl)
+
+ const entry = {
+ actorId: actor.id,
+ videoId: video.id,
+ url: shareUrl
+ }
+
+ await VideoShareModel.upsert(entry)
+}
+
+async function shareByServer (video: MVideo, t: Transaction) {