-
-async function processUpdateVideoChannel (account: AccountInstance, videoChannel: VideoChannelObject) {
- const options = {
- arguments: [ account, videoChannel ],
- errorMessage: 'Cannot update the remote video channel with many retries.'
- }
-
- await retryTransactionWrapper(updateRemoteVideoChannel, options)
-}
-
-async function updateRemoteVideoChannel (account: AccountInstance, videoChannel: VideoChannelObject) {
- logger.debug('Updating remote video channel "%s".', videoChannel.uuid)
-
- await db.sequelize.transaction(async t => {
- const sequelizeOptions = { transaction: t }
-
- const videoChannelInstance = await db.VideoChannel.loadByUrl(videoChannel.id)
- if (!videoChannelInstance) throw new Error('Video ' + videoChannel.id + ' not found.')
-
- if (videoChannelInstance.Account.id !== account.id) {
- throw new Error('Account ' + account.id + ' does not own video channel ' + videoChannelInstance.url)
- }
-
- videoChannelInstance.set('name', videoChannel.name)
- videoChannelInstance.set('description', videoChannel.content)
- videoChannelInstance.set('createdAt', videoChannel.published)
- videoChannelInstance.set('updatedAt', videoChannel.updated)
-
- await videoChannelInstance.save(sequelizeOptions)
- })
-
- logger.info('Remote video channel with uuid %s updated', videoChannel.uuid)
-}