]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video.js
Server: use video hook to send information to other pods when a video is
[github/Chocobozzz/PeerTube.git] / server / models / video.js
index 3ebc48ad4d66ec5bc4faa8a370c5178e1abedf8c..564e362fdd244fbf85a3d7b2dbb6a1b2d3ee3817 100644 (file)
@@ -12,6 +12,7 @@ const values = require('lodash/values')
 
 const constants = require('../initializers/constants')
 const logger = require('../helpers/logger')
+const friends = require('../lib/friends')
 const modelUtils = require('./utils')
 const customVideosValidators = require('../helpers/custom-validators').videos
 
@@ -82,6 +83,26 @@ module.exports = function (sequelize, DataTypes) {
       }
     },
     {
+      indexes: [
+        {
+          fields: [ 'authorId' ]
+        },
+        {
+          fields: [ 'remoteId' ]
+        },
+        {
+          fields: [ 'name' ]
+        },
+        {
+          fields: [ 'createdAt' ]
+        },
+        {
+          fields: [ 'duration' ]
+        },
+        {
+          fields: [ 'infoHash' ]
+        }
+      ],
       classMethods: {
         associate,
 
@@ -185,11 +206,24 @@ function afterDestroy (video, options, next) {
       function (callback) {
         removeFile(video, callback)
       },
+
       function (callback) {
         removeTorrent(video, callback)
       },
+
       function (callback) {
         removePreview(video, callback)
+      },
+
+      function (callback) {
+        const params = {
+          name: video.name,
+          remoteId: video.id
+        }
+
+        friends.removeVideoToFriends(params)
+
+        return callback()
       }
     )
   }