VIDEO_PRIVACIES
} from '../../../initializers'
import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub'
-import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send'
+import { sendCreateVideo, sendCreateView, sendUpdateVideo } from '../../../lib/activitypub/send'
import { JobQueue } from '../../../lib/job-queue'
import { Redis } from '../../../lib/redis'
import {
if (videoInfoToUpdate.licence !== undefined) videoInstance.set('licence', videoInfoToUpdate.licence)
if (videoInfoToUpdate.language !== undefined) videoInstance.set('language', videoInfoToUpdate.language)
if (videoInfoToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfoToUpdate.nsfw)
- if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', parseInt(videoInfoToUpdate.privacy.toString(), 10))
if (videoInfoToUpdate.support !== undefined) videoInstance.set('support', videoInfoToUpdate.support)
if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.set('commentsEnabled', videoInfoToUpdate.commentsEnabled)
+ if (videoInfoToUpdate.privacy !== undefined) {
+ const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)
+ videoInstance.set('privacy', newPrivacy)
+
+ if (wasPrivateVideo === true && newPrivacy !== VideoPrivacy.PRIVATE) {
+ videoInstance.set('publishedAt', new Date())
+ }
+ }
const videoInstanceUpdated = await videoInstance.save(sequelizeOptions)
const serverAccount = await getServerActor()
- if (videoInstance.isOwned()) {
- await sendCreateViewToVideoFollowers(serverAccount, videoInstance, undefined)
- } else {
- await sendCreateViewToOrigin(serverAccount, videoInstance, undefined)
- }
+ await sendCreateView(serverAccount, videoInstance, undefined)
return res.status(204).end()
}
}
async function searchVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
- const resultList = await VideoModel.searchAndPopulateAccountAndServerAndTags(
+ const resultList = await VideoModel.searchAndPopulateAccountAndServer(
req.query.search,
req.query.start,
req.query.count,