import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared'
import { getFormattedObjects, logger, resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers'
import { sequelizeTypescript } from '../../../initializers'
-import { createVideoChannel } from '../../../lib'
-import { sendUpdateVideoChannel } from '../../../lib/activitypub/send/send-update'
+import { setAsyncActorKeys } from '../../../lib/activitypub'
+import { createVideoChannel } from '../../../lib/video-channel'
import {
asyncMiddleware,
authenticate,
async function addVideoChannel (req: express.Request, res: express.Response) {
const videoChannelInfo: VideoChannelCreate = req.body
const account: AccountModel = res.locals.oauth.token.User.Account
- let videoChannelCreated: VideoChannelModel
- await sequelizeTypescript.transaction(async t => {
- videoChannelCreated = await createVideoChannel(videoChannelInfo, account, t)
+ const videoChannelCreated = await sequelizeTypescript.transaction(async t => {
+ return createVideoChannel(videoChannelInfo, account, t)
})
- logger.info('Video channel with uuid %s created.', videoChannelCreated.uuid)
+ setAsyncActorKeys(videoChannelCreated.Actor)
+
+ logger.info('Video channel with uuid %s created.', videoChannelCreated.Actor.uuid)
}
async function updateVideoChannelRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {
if (videoChannelInfoToUpdate.name !== undefined) videoChannelInstance.set('name', videoChannelInfoToUpdate.name)
if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.set('description', videoChannelInfoToUpdate.description)
- const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions)
+ await videoChannelInstance.save(sequelizeOptions)
- await sendUpdateVideoChannel(videoChannelInstanceUpdated, t)
+ // TODO
+ // await sendUpdateVideoChannel(videoChannelInstanceUpdated, t)
})
- logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.uuid)
+ logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.Actor.uuid)
} catch (err) {
logger.debug('Cannot update the video channel.', err)
async function removeVideoChannel (req: express.Request, res: express.Response) {
const videoChannelInstance: VideoChannelModel = res.locals.videoChannel
- await sequelizeTypescript.transaction(async t => {
+ return sequelizeTypescript.transaction(async t => {
await videoChannelInstance.destroy({ transaction: t })
+
+ logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.Actor.uuid)
})
- logger.info('Video channel with name %s and uuid %s deleted.', videoChannelInstance.name, videoChannelInstance.uuid)
}
async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) {