X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fprocess%2Fprocess-create.ts;h=4740dc4328d5fd7e6ef521e52b34220128b9ca47;hb=f00984c0077e9b666fe8005452768e53d1c3f421;hp=1f982598bca7af981de7edd9c643e71bfdecbee7;hpb=63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 1f982598b..4740dc432 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -8,7 +8,7 @@ import { AccountInstance } from '../../../models/account/account-interface' import { getOrCreateAccountAndServer } from '../account' import { forwardActivity } from '../send/misc' import { getVideoChannelActivityPubUrl } from '../url' -import { videoChannelActivityObjectToDBAttributes } from './misc' +import { addVideoChannelShares, videoChannelActivityObjectToDBAttributes } from './misc' async function processCreateActivity (activity: ActivityCreate) { const activityObject = activity.object @@ -63,7 +63,7 @@ function createVideoDislike (byAccount: AccountInstance, activity: ActivityCreat defaults: rate, transaction: t }) - await video.increment('dislikes', { transaction: t }) + if (created === true) await video.increment('dislikes', { transaction: t }) if (video.isOwned() && created === true) { // Don't resend the activity to the sender @@ -92,13 +92,19 @@ async function processCreateView (byAccount: AccountInstance, activity: Activity } } -function processCreateVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { +async function processCreateVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { const options = { arguments: [ account, videoChannelToCreateData ], errorMessage: 'Cannot insert the remote video channel with many retries.' } - return retryTransactionWrapper(addRemoteVideoChannel, options) + const videoChannel = await retryTransactionWrapper(addRemoteVideoChannel, options) + + if (videoChannelToCreateData.shares && Array.isArray(videoChannelToCreateData.shares.orderedItems)) { + await addVideoChannelShares(videoChannel, videoChannelToCreateData.shares.orderedItems) + } + + return videoChannel } function addRemoteVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) {