mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Make it compile at least
This commit is contained in:
parent
38fa206583
commit
571389d43b
53 changed files with 342 additions and 1256 deletions
|
@ -5,8 +5,6 @@ import { badRequest } from '../../helpers'
|
|||
import { oauthClientsRouter } from './oauth-clients'
|
||||
import { configRouter } from './config'
|
||||
import { podsRouter } from './pods'
|
||||
import { remoteRouter } from './remote'
|
||||
import { requestSchedulerRouter } from './request-schedulers'
|
||||
import { usersRouter } from './users'
|
||||
import { videosRouter } from './videos'
|
||||
|
||||
|
@ -15,8 +13,6 @@ const apiRouter = express.Router()
|
|||
apiRouter.use('/oauth-clients', oauthClientsRouter)
|
||||
apiRouter.use('/config', configRouter)
|
||||
apiRouter.use('/pods', podsRouter)
|
||||
apiRouter.use('/remote', remoteRouter)
|
||||
apiRouter.use('/request-schedulers', requestSchedulerRouter)
|
||||
apiRouter.use('/users', usersRouter)
|
||||
apiRouter.use('/videos', videosRouter)
|
||||
apiRouter.use('/ping', pong)
|
||||
|
|
|
@ -1,26 +1,7 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { getFormattedObjects } from '../../helpers'
|
||||
import { database as db } from '../../initializers/database'
|
||||
import { logger, getFormattedObjects } from '../../helpers'
|
||||
import {
|
||||
makeFriends,
|
||||
quitFriends,
|
||||
removeFriend
|
||||
} from '../../lib'
|
||||
import {
|
||||
authenticate,
|
||||
ensureUserHasRight,
|
||||
makeFriendsValidator,
|
||||
setBodyHostsPort,
|
||||
podRemoveValidator,
|
||||
paginationValidator,
|
||||
setPagination,
|
||||
setPodsSort,
|
||||
podsSortValidator,
|
||||
asyncMiddleware
|
||||
} from '../../middlewares'
|
||||
import { PodInstance } from '../../models'
|
||||
import { UserRight } from '../../../shared'
|
||||
import { asyncMiddleware, paginationValidator, podsSortValidator, setPagination, setPodsSort } from '../../middlewares'
|
||||
|
||||
const podsRouter = express.Router()
|
||||
|
||||
|
@ -31,24 +12,6 @@ podsRouter.get('/',
|
|||
setPagination,
|
||||
asyncMiddleware(listPods)
|
||||
)
|
||||
podsRouter.post('/make-friends',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PODS),
|
||||
makeFriendsValidator,
|
||||
setBodyHostsPort,
|
||||
asyncMiddleware(makeFriendsController)
|
||||
)
|
||||
podsRouter.get('/quit-friends',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PODS),
|
||||
asyncMiddleware(quitFriendsController)
|
||||
)
|
||||
podsRouter.delete('/:id',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PODS),
|
||||
podRemoveValidator,
|
||||
asyncMiddleware(removeFriendController)
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
@ -63,28 +26,3 @@ async function listPods (req: express.Request, res: express.Response, next: expr
|
|||
|
||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
}
|
||||
|
||||
async function makeFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const hosts = req.body.hosts as string[]
|
||||
|
||||
// Don't wait the process that could be long
|
||||
makeFriends(hosts)
|
||||
.then(() => logger.info('Made friends!'))
|
||||
.catch(err => logger.error('Could not make friends.', err))
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
}
|
||||
|
||||
async function quitFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
await quitFriends()
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
}
|
||||
|
||||
async function removeFriendController (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const pod = res.locals.pod as PodInstance
|
||||
|
||||
await removeFriend(pod)
|
||||
|
||||
return res.type('json').status(204).end()
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
import * as express from 'express'
|
||||
import * as Bluebird from 'bluebird'
|
||||
|
||||
import {
|
||||
AbstractRequestScheduler,
|
||||
getRequestScheduler,
|
||||
getRequestVideoQaduScheduler,
|
||||
getRequestVideoEventScheduler
|
||||
} from '../../lib'
|
||||
import { authenticate, ensureUserHasRight, asyncMiddleware } from '../../middlewares'
|
||||
import { RequestSchedulerStatsAttributes, UserRight } from '../../../shared'
|
||||
|
||||
const requestSchedulerRouter = express.Router()
|
||||
|
||||
requestSchedulerRouter.get('/stats',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_REQUEST_SCHEDULERS),
|
||||
asyncMiddleware(getRequestSchedulersStats)
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
requestSchedulerRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function getRequestSchedulersStats (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const result = await Bluebird.props({
|
||||
requestScheduler: buildRequestSchedulerStats(getRequestScheduler()),
|
||||
requestVideoQaduScheduler: buildRequestSchedulerStats(getRequestVideoQaduScheduler()),
|
||||
requestVideoEventScheduler: buildRequestSchedulerStats(getRequestVideoEventScheduler())
|
||||
})
|
||||
|
||||
return res.json(result)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function buildRequestSchedulerStats (requestScheduler: AbstractRequestScheduler<any>) {
|
||||
const count = await requestScheduler.remainingRequestsCount()
|
||||
|
||||
const result: RequestSchedulerStatsAttributes = {
|
||||
totalRequests: count,
|
||||
requestsLimitPods: requestScheduler.limitPods,
|
||||
requestsLimitPerPod: requestScheduler.limitPerPod,
|
||||
remainingMilliSeconds: requestScheduler.remainingMilliSeconds(),
|
||||
milliSecondsInterval: requestScheduler.requestInterval
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
|
@ -1,37 +1,29 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { database as db, CONFIG } from '../../initializers'
|
||||
import { logger, getFormattedObjects, retryTransactionWrapper } from '../../helpers'
|
||||
import { UserCreate, UserRight, UserRole, UserUpdate, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../shared'
|
||||
import { getFormattedObjects, logger, retryTransactionWrapper } from '../../helpers'
|
||||
import { CONFIG, database as db } from '../../initializers'
|
||||
import { createUserAccountAndChannel } from '../../lib'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
authenticate,
|
||||
ensureUserHasRight,
|
||||
ensureUserRegistrationAllowed,
|
||||
usersAddValidator,
|
||||
usersRegisterValidator,
|
||||
usersUpdateValidator,
|
||||
usersUpdateMeValidator,
|
||||
usersRemoveValidator,
|
||||
usersVideoRatingValidator,
|
||||
usersGetValidator,
|
||||
paginationValidator,
|
||||
setPagination,
|
||||
usersSortValidator,
|
||||
setUsersSort,
|
||||
token,
|
||||
asyncMiddleware
|
||||
usersAddValidator,
|
||||
usersGetValidator,
|
||||
usersRegisterValidator,
|
||||
usersRemoveValidator,
|
||||
usersSortValidator,
|
||||
usersUpdateMeValidator,
|
||||
usersUpdateValidator,
|
||||
usersVideoRatingValidator
|
||||
} from '../../middlewares'
|
||||
import {
|
||||
UserVideoRate as FormattedUserVideoRate,
|
||||
UserCreate,
|
||||
UserUpdate,
|
||||
UserUpdateMe,
|
||||
UserRole,
|
||||
UserRight
|
||||
} from '../../../shared'
|
||||
import { createUserAccountAndChannel } from '../../lib'
|
||||
import { UserInstance } from '../../models'
|
||||
import { videosSortValidator } from '../../middlewares/validators/sort'
|
||||
import { setVideosSort } from '../../middlewares/sort'
|
||||
import { videosSortValidator } from '../../middlewares/validators/sort'
|
||||
import { UserInstance } from '../../models'
|
||||
|
||||
const usersRouter = express.Router()
|
||||
|
||||
|
@ -176,9 +168,9 @@ function getUser (req: express.Request, res: express.Response, next: express.Nex
|
|||
|
||||
async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const videoId = +req.params.videoId
|
||||
const userId = +res.locals.oauth.token.User.id
|
||||
const accountId = +res.locals.oauth.token.User.Account.id
|
||||
|
||||
const ratingObj = await db.UserVideoRate.load(userId, videoId, null)
|
||||
const ratingObj = await db.AccountVideoRate.load(accountId, videoId, null)
|
||||
const rating = ratingObj ? ratingObj.type : 'none'
|
||||
|
||||
const json: FormattedUserVideoRate = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import * as friends from '../../../lib/friends'
|
||||
import {
|
||||
logger,
|
||||
getFormattedObjects,
|
||||
|
@ -84,7 +83,8 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
|
|||
videoUUID: videoInstance.uuid
|
||||
}
|
||||
|
||||
await friends.reportAbuseVideoToFriend(reportData, videoInstance, t)
|
||||
// await friends.reportAbuseVideoToFriend(reportData, videoInstance, t)
|
||||
// TODO: send abuse to origin pod
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { database as db } from '../../../initializers'
|
||||
import {
|
||||
logger,
|
||||
getFormattedObjects,
|
||||
retryTransactionWrapper,
|
||||
resetSequelizeInstance
|
||||
} from '../../../helpers'
|
||||
import {
|
||||
authenticate,
|
||||
paginationValidator,
|
||||
videoChannelsSortValidator,
|
||||
videoChannelsAddValidator,
|
||||
setVideoChannelsSort,
|
||||
setPagination,
|
||||
videoChannelsRemoveValidator,
|
||||
videoChannelGetValidator,
|
||||
videoChannelsUpdateValidator,
|
||||
listVideoAccountChannelsValidator,
|
||||
asyncMiddleware
|
||||
} from '../../../middlewares'
|
||||
import {
|
||||
createVideoChannel,
|
||||
updateVideoChannelToFriends
|
||||
} from '../../../lib'
|
||||
import { VideoChannelInstance, AccountInstance } from '../../../models'
|
||||
import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared'
|
||||
import { getFormattedObjects, logger, resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers'
|
||||
import { database as db } from '../../../initializers'
|
||||
import { createVideoChannel } from '../../../lib'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
authenticate,
|
||||
listVideoAccountChannelsValidator,
|
||||
paginationValidator,
|
||||
setPagination,
|
||||
setVideoChannelsSort,
|
||||
videoChannelGetValidator,
|
||||
videoChannelsAddValidator,
|
||||
videoChannelsRemoveValidator,
|
||||
videoChannelsSortValidator,
|
||||
videoChannelsUpdateValidator
|
||||
} from '../../../middlewares'
|
||||
import { AccountInstance, VideoChannelInstance } from '../../../models'
|
||||
import { sendUpdateVideoChannel } from '../../../lib/activitypub/send-request'
|
||||
|
||||
const videoChannelRouter = express.Router()
|
||||
|
||||
|
@ -137,11 +129,8 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
|
|||
if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.set('description', videoChannelInfoToUpdate.description)
|
||||
|
||||
await videoChannelInstance.save(sequelizeOptions)
|
||||
const json = videoChannelInstance.toUpdateRemoteJSON()
|
||||
|
||||
// Now we'll update the video channel's meta data to our friends
|
||||
return updateVideoChannelToFriends(json, t)
|
||||
|
||||
await sendUpdateVideoChannel(videoChannelInstance, t)
|
||||
})
|
||||
|
||||
logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.uuid)
|
||||
|
|
|
@ -1,57 +1,41 @@
|
|||
import * as express from 'express'
|
||||
import * as multer from 'multer'
|
||||
import { extname, join } from 'path'
|
||||
|
||||
import { VideoCreate, VideoPrivacy, VideoUpdate } from '../../../../shared'
|
||||
import {
|
||||
fetchRemoteVideoDescription,
|
||||
generateRandomString,
|
||||
getFormattedObjects,
|
||||
getVideoFileHeight,
|
||||
logger,
|
||||
renamePromise,
|
||||
resetSequelizeInstance,
|
||||
retryTransactionWrapper
|
||||
} from '../../../helpers'
|
||||
import { getActivityPubUrl } from '../../../helpers/activitypub'
|
||||
import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers'
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import { sendAddVideo, sendUpdateVideoChannel } from '../../../lib/activitypub/send-request'
|
||||
import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler'
|
||||
import {
|
||||
CONFIG,
|
||||
REQUEST_VIDEO_QADU_TYPES,
|
||||
REQUEST_VIDEO_EVENT_TYPES,
|
||||
VIDEO_CATEGORIES,
|
||||
VIDEO_LICENCES,
|
||||
VIDEO_LANGUAGES,
|
||||
VIDEO_PRIVACIES,
|
||||
VIDEO_MIMETYPE_EXT
|
||||
} from '../../../initializers'
|
||||
import {
|
||||
addEventToRemoteVideo,
|
||||
quickAndDirtyUpdateVideoToFriends,
|
||||
addVideoToFriends,
|
||||
updateVideoToFriends,
|
||||
JobScheduler,
|
||||
fetchRemoteDescription
|
||||
} from '../../../lib'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
authenticate,
|
||||
paginationValidator,
|
||||
videosSortValidator,
|
||||
setVideosSort,
|
||||
setPagination,
|
||||
setVideosSearch,
|
||||
videosUpdateValidator,
|
||||
videosSearchValidator,
|
||||
setVideosSort,
|
||||
videosAddValidator,
|
||||
videosGetValidator,
|
||||
videosRemoveValidator,
|
||||
asyncMiddleware
|
||||
videosSearchValidator,
|
||||
videosSortValidator,
|
||||
videosUpdateValidator
|
||||
} from '../../../middlewares'
|
||||
import {
|
||||
logger,
|
||||
retryTransactionWrapper,
|
||||
generateRandomString,
|
||||
getFormattedObjects,
|
||||
renamePromise,
|
||||
getVideoFileHeight,
|
||||
resetSequelizeInstance
|
||||
} from '../../../helpers'
|
||||
import { VideoInstance } from '../../../models'
|
||||
import { VideoCreate, VideoUpdate, VideoPrivacy } from '../../../../shared'
|
||||
|
||||
import { abuseVideoRouter } from './abuse'
|
||||
import { blacklistRouter } from './blacklist'
|
||||
import { rateVideoRouter } from './rate'
|
||||
import { videoChannelRouter } from './channel'
|
||||
import { getActivityPubUrl } from '../../../helpers/activitypub'
|
||||
import { rateVideoRouter } from './rate'
|
||||
|
||||
const videosRouter = express.Router()
|
||||
|
||||
|
@ -225,7 +209,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
|
|||
}
|
||||
|
||||
tasks.push(
|
||||
JobScheduler.Instance.createJob(t, 'videoFileOptimizer', dataInput)
|
||||
transcodingJobScheduler.createJob(t, 'videoFileOptimizer', dataInput)
|
||||
)
|
||||
}
|
||||
await Promise.all(tasks)
|
||||
|
@ -252,9 +236,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
|
|||
// Don't send video to remote pods, it is private
|
||||
if (video.privacy === VideoPrivacy.PRIVATE) return undefined
|
||||
|
||||
const remoteVideo = await video.toAddRemoteJSON()
|
||||
// Now we'll add the video's meta data to our friends
|
||||
return addVideoToFriends(remoteVideo, t)
|
||||
await sendAddVideo(video, t)
|
||||
})
|
||||
|
||||
logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoUUID)
|
||||
|
@ -302,14 +284,12 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
|||
|
||||
// Now we'll update the video's meta data to our friends
|
||||
if (wasPrivateVideo === false) {
|
||||
const json = videoInstance.toUpdateRemoteJSON()
|
||||
return updateVideoToFriends(json, t)
|
||||
await sendUpdateVideoChannel(videoInstance, t)
|
||||
}
|
||||
|
||||
// Video is not private anymore, send a create action to remote pods
|
||||
if (wasPrivateVideo === true && videoInstance.privacy !== VideoPrivacy.PRIVATE) {
|
||||
const remoteVideo = await videoInstance.toAddRemoteJSON()
|
||||
return addVideoToFriends(remoteVideo, t)
|
||||
await sendAddVideo(videoInstance, t)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -324,7 +304,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
|||
}
|
||||
}
|
||||
|
||||
function getVideo (req: express.Request, res: express.Response) {
|
||||
async function getVideo (req: express.Request, res: express.Response) {
|
||||
const videoInstance = res.locals.video
|
||||
|
||||
if (videoInstance.isOwned()) {
|
||||
|
@ -333,21 +313,11 @@ function getVideo (req: express.Request, res: express.Response) {
|
|||
// For example, only add a view when a user watch a video during 30s etc
|
||||
videoInstance.increment('views')
|
||||
.then(() => {
|
||||
const qaduParams = {
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_QADU_TYPES.VIEWS
|
||||
}
|
||||
return quickAndDirtyUpdateVideoToFriends(qaduParams)
|
||||
// TODO: send to followers a notification
|
||||
})
|
||||
.catch(err => logger.error('Cannot add view to video %s.', videoInstance.uuid, err))
|
||||
} else {
|
||||
// Just send the event to our friends
|
||||
const eventParams = {
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_EVENT_TYPES.VIEWS
|
||||
}
|
||||
addEventToRemoteVideo(eventParams)
|
||||
.catch(err => logger.error('Cannot add event to remote video %s.', videoInstance.uuid, err))
|
||||
// TODO: send view event to followers
|
||||
}
|
||||
|
||||
// Do not wait the view system
|
||||
|
@ -361,7 +331,7 @@ async function getVideoDescription (req: express.Request, res: express.Response)
|
|||
if (videoInstance.isOwned()) {
|
||||
description = videoInstance.description
|
||||
} else {
|
||||
description = await fetchRemoteDescription(videoInstance)
|
||||
description = await fetchRemoteVideoDescription(videoInstance)
|
||||
}
|
||||
|
||||
return res.json({ description })
|
||||
|
|
|
@ -1,25 +1,11 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import {
|
||||
logger,
|
||||
retryTransactionWrapper
|
||||
} from '../../../helpers'
|
||||
import {
|
||||
VIDEO_RATE_TYPES,
|
||||
REQUEST_VIDEO_EVENT_TYPES,
|
||||
REQUEST_VIDEO_QADU_TYPES
|
||||
} from '../../../initializers'
|
||||
import {
|
||||
addEventsToRemoteVideo,
|
||||
quickAndDirtyUpdatesVideoToFriends
|
||||
} from '../../../lib'
|
||||
import {
|
||||
authenticate,
|
||||
videoRateValidator,
|
||||
asyncMiddleware
|
||||
} from '../../../middlewares'
|
||||
import { UserVideoRateUpdate } from '../../../../shared'
|
||||
import { logger, retryTransactionWrapper } from '../../../helpers'
|
||||
import { VIDEO_RATE_TYPES } from '../../../initializers'
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares'
|
||||
import { AccountInstance } from '../../../models/account/account-interface'
|
||||
import { VideoInstance } from '../../../models/video/video-interface'
|
||||
|
||||
const rateVideoRouter = express.Router()
|
||||
|
||||
|
@ -51,12 +37,12 @@ async function rateVideoRetryWrapper (req: express.Request, res: express.Respons
|
|||
async function rateVideo (req: express.Request, res: express.Response) {
|
||||
const body: UserVideoRateUpdate = req.body
|
||||
const rateType = body.rating
|
||||
const videoInstance = res.locals.video
|
||||
const userInstance = res.locals.oauth.token.User
|
||||
const videoInstance: VideoInstance = res.locals.video
|
||||
const accountInstance: AccountInstance = res.locals.oauth.token.User.Account
|
||||
|
||||
await db.sequelize.transaction(async t => {
|
||||
const sequelizeOptions = { transaction: t }
|
||||
const previousRate = await db.UserVideoRate.load(userInstance.id, videoInstance.id, t)
|
||||
const previousRate = await db.AccountVideoRate.load(accountInstance.id, videoInstance.id, t)
|
||||
|
||||
let likesToIncrement = 0
|
||||
let dislikesToIncrement = 0
|
||||
|
@ -79,12 +65,12 @@ async function rateVideo (req: express.Request, res: express.Response) {
|
|||
}
|
||||
} else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate
|
||||
const query = {
|
||||
userId: userInstance.id,
|
||||
accountId: accountInstance.id,
|
||||
videoId: videoInstance.id,
|
||||
type: rateType
|
||||
}
|
||||
|
||||
await db.UserVideoRate.create(query, sequelizeOptions)
|
||||
await db.AccountVideoRate.create(query, sequelizeOptions)
|
||||
}
|
||||
|
||||
const incrementQuery = {
|
||||
|
@ -96,48 +82,12 @@ async function rateVideo (req: express.Request, res: express.Response) {
|
|||
// It is useful for the user to have a feedback
|
||||
await videoInstance.increment(incrementQuery, sequelizeOptions)
|
||||
|
||||
// Send a event to original pod
|
||||
if (videoInstance.isOwned() === false) {
|
||||
|
||||
const eventsParams = []
|
||||
|
||||
if (likesToIncrement !== 0) {
|
||||
eventsParams.push({
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_EVENT_TYPES.LIKES,
|
||||
count: likesToIncrement
|
||||
})
|
||||
}
|
||||
|
||||
if (dislikesToIncrement !== 0) {
|
||||
eventsParams.push({
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_EVENT_TYPES.DISLIKES,
|
||||
count: dislikesToIncrement
|
||||
})
|
||||
}
|
||||
|
||||
await addEventsToRemoteVideo(eventsParams, t)
|
||||
} else { // We own the video, we need to send a quick and dirty update to friends to notify the counts changed
|
||||
const qadusParams = []
|
||||
|
||||
if (likesToIncrement !== 0) {
|
||||
qadusParams.push({
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_QADU_TYPES.LIKES
|
||||
})
|
||||
}
|
||||
|
||||
if (dislikesToIncrement !== 0) {
|
||||
qadusParams.push({
|
||||
videoId: videoInstance.id,
|
||||
type: REQUEST_VIDEO_QADU_TYPES.DISLIKES
|
||||
})
|
||||
}
|
||||
|
||||
await quickAndDirtyUpdatesVideoToFriends(qadusParams, t)
|
||||
// TODO: Send a event to original pod
|
||||
} else {
|
||||
// TODO: Send update to followers
|
||||
}
|
||||
})
|
||||
|
||||
logger.info('User video rate for video %s of user %s updated.', videoInstance.name, userInstance.username)
|
||||
logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue