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
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
}
}
-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) {