1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add gitlab ci support

This commit is contained in:
Chocobozzz 2019-07-29 11:59:29 +02:00
parent 112be80ebd
commit 2284f20207
No known key found for this signature in database
GPG key ID: 583A612D890159BE
36 changed files with 247 additions and 64 deletions

View file

@ -31,7 +31,7 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: flag.object })
return sequelizeTypescript.transaction(async t => {
const videoAbuse = await sequelizeTypescript.transaction(async t => {
const videoAbuseData = {
reporterAccountId: account.id,
reason: flag.content,
@ -42,8 +42,10 @@ async function processCreateVideoAbuse (activity: ActivityCreate | ActivityFlag,
const videoAbuseInstance = await VideoAbuseModel.create(videoAbuseData, { transaction: t })
videoAbuseInstance.Video = video
Notifier.Instance.notifyOnNewVideoAbuse(videoAbuseInstance)
logger.info('Remote abuse for video uuid %s created', flag.object)
return videoAbuseInstance
})
Notifier.Instance.notifyOnNewVideoAbuse(videoAbuse)
}

View file

@ -11,6 +11,7 @@ import { VideoRedundancyModel } from '../../../models/redundancy/video-redundanc
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
import { getServerActor } from '../../../helpers/utils'
import * as Bluebird from 'bluebird'
async function sendCreateVideo (video: VideoModel, t: Transaction) {
if (video.privacy === VideoPrivacy.PRIVATE) return undefined
@ -82,7 +83,7 @@ async function sendCreateVideoComment (comment: VideoCommentModel, t: Transactio
// This was a reply, send it to the parent actors
const actorsException = [ byActor ]
await broadcastToActors(createActivity, byActor, parentsCommentActors, actorsException)
await broadcastToActors(createActivity, byActor, parentsCommentActors, t, actorsException)
// Broadcast to our followers
await broadcastToFollowers(createActivity, byActor, [ byActor ], t)
@ -91,7 +92,7 @@ async function sendCreateVideoComment (comment: VideoCommentModel, t: Transactio
if (isOrigin) return broadcastToFollowers(createActivity, byActor, actorsInvolvedInComment, t, actorsException)
// Send to origin
return unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl)
t.afterCommit(() => unicastTo(createActivity, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl))
}
function buildCreateActivity (url: string, byActor: ActorModel, object: any, audience?: ActivityAudience): ActivityCreate {

View file

@ -59,7 +59,7 @@ async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Trans
// This was a reply, send it to the parent actors
const actorsException = [ byActor ]
await broadcastToActors(activity, byActor, threadParentComments.map(c => c.Account.Actor), actorsException)
await broadcastToActors(activity, byActor, threadParentComments.map(c => c.Account.Actor), t, actorsException)
// Broadcast to our followers
await broadcastToFollowers(activity, byActor, [ byActor ], t)
@ -68,7 +68,7 @@ async function sendDeleteVideoComment (videoComment: VideoCommentModel, t: Trans
if (isVideoOrigin) return broadcastToFollowers(activity, byActor, actorsInvolvedInComment, t, actorsException)
// Send to origin
return unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl)
t.afterCommit(() => unicastTo(activity, byActor, videoComment.Video.VideoChannel.Account.Actor.sharedInboxUrl))
}
async function sendDeleteVideoPlaylist (videoPlaylist: VideoPlaylistModel, t: Transaction) {

View file

@ -6,8 +6,9 @@ import { unicastTo } from './utils'
import { logger } from '../../../helpers/logger'
import { ActivityAudience, ActivityFlag } from '../../../../shared/models/activitypub'
import { audiencify, getAudience } from '../audience'
import { Transaction } from 'sequelize'
async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel, video: VideoModel) {
async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel, video: VideoModel, t: Transaction) {
if (!video.VideoChannel.Account.Actor.serverId) return // Local user
const url = getVideoAbuseActivityPubUrl(videoAbuse)
@ -18,7 +19,7 @@ async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel,
const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] }
const flagActivity = buildFlagActivity(url, byActor, videoAbuse, audience)
return unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl))
}
function buildFlagActivity (url: string, byActor: ActorModel, videoAbuse: VideoAbuseModel, audience: ActivityAudience): ActivityFlag {

View file

@ -4,8 +4,9 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { getActorFollowActivityPubUrl } from '../url'
import { unicastTo } from './utils'
import { logger } from '../../../helpers/logger'
import { Transaction } from 'sequelize'
function sendFollow (actorFollow: ActorFollowModel) {
function sendFollow (actorFollow: ActorFollowModel, t: Transaction) {
const me = actorFollow.ActorFollower
const following = actorFollow.ActorFollowing
@ -17,7 +18,7 @@ function sendFollow (actorFollow: ActorFollowModel) {
const url = getActorFollowActivityPubUrl(me, following)
const data = buildFollowActivity(url, me, following)
return unicastTo(data, me, following.inboxUrl)
t.afterCommit(() => unicastTo(data, me, following.inboxUrl))
}
function buildFollowActivity (url: string, byActor: ActorModel, targetActor: ActorModel): ActivityFollow {

View file

@ -37,7 +37,7 @@ async function sendUndoFollow (actorFollow: ActorFollowModel, t: Transaction) {
const followActivity = buildFollowActivity(followUrl, me, following)
const undoActivity = undoActivityData(undoUrl, me, followActivity)
return unicastTo(undoActivity, me, following.inboxUrl)
t.afterCommit(() => unicastTo(undoActivity, me, following.inboxUrl))
}
async function sendUndoAnnounce (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {

View file

@ -26,7 +26,9 @@ async function sendUpdateVideo (video: VideoModel, t: Transaction, overrodeByAct
const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString())
// Needed to build the AP object
if (!video.VideoCaptions) video.VideoCaptions = await video.$get('VideoCaptions') as VideoCaptionModel[]
if (!video.VideoCaptions) {
video.VideoCaptions = await video.$get('VideoCaptions', { transaction: t }) as VideoCaptionModel[]
}
const videoObject = video.toActivityPubObject()
const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC)

View file

@ -7,6 +7,7 @@ import { JobQueue } from '../../job-queue'
import { VideoModel } from '../../../models/video/video'
import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience'
import { getServerActor } from '../../../helpers/utils'
import { afterCommitIfTransaction } from '../../../helpers/database-utils'
async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: {
byActor: ActorModel,
@ -20,7 +21,9 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
const audience = getRemoteVideoAudience(options.video, actorsInvolvedInVideo)
const activity = activityBuilder(audience)
return unicastTo(activity, options.byActor, options.video.VideoChannel.Account.Actor.sharedInboxUrl)
return afterCommitIfTransaction(options.transaction, () => {
return unicastTo(activity, options.byActor, options.video.VideoChannel.Account.Actor.sharedInboxUrl)
})
}
// Send to followers
@ -28,6 +31,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
const activity = activityBuilder(audience)
const actorsException = [ options.byActor ]
return broadcastToFollowers(activity, options.byActor, actorsInvolvedInVideo, options.transaction, actorsException)
}
@ -76,7 +80,7 @@ async function forwardActivity (
uris,
body: activity
}
return JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload })
return afterCommitIfTransaction(t, () => JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload }))
}
async function broadcastToFollowers (
@ -87,20 +91,22 @@ async function broadcastToFollowers (
actorsException: ActorModel[] = []
) {
const uris = await computeFollowerUris(toFollowersOf, actorsException, t)
return broadcastTo(uris, data, byActor)
return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor))
}
async function broadcastToActors (
data: any,
byActor: ActorModel,
toActors: ActorModel[],
t?: Transaction,
actorsException: ActorModel[] = []
) {
const uris = await computeUris(toActors, actorsException)
return broadcastTo(uris, data, byActor)
return afterCommitIfTransaction(t, () => broadcastTo(uris, data, byActor))
}
async function broadcastTo (uris: string[], data: any, byActor: ActorModel) {
function broadcastTo (uris: string[], data: any, byActor: ActorModel) {
if (uris.length === 0) return undefined
logger.debug('Creating broadcast job.', { uris })
@ -114,7 +120,7 @@ async function broadcastTo (uris: string[], data: any, byActor: ActorModel) {
return JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload })
}
async function unicastTo (data: any, byActor: ActorModel, toActorUrl: string) {
function unicastTo (data: any, byActor: ActorModel, toActorUrl: string) {
logger.debug('Creating unicast job.', { uri: toActorUrl })
const payload = {
@ -123,7 +129,7 @@ async function unicastTo (data: any, byActor: ActorModel, toActorUrl: string) {
body: data
}
return JobQueue.Instance.createJob({ type: 'activitypub-http-unicast', payload })
JobQueue.Instance.createJob({ type: 'activitypub-http-unicast', payload })
}
// ---------------------------------------------------------------------------