+ static checkVideoHasInstanceFollow (videoId: number, followerActorId: number) {
+ // Instances only share videos
+ const query = 'SELECT 1 FROM "videoShare" ' +
+ 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' +
+ 'WHERE "actorFollow"."actorId" = $followerActorId AND "videoShare"."videoId" = $videoId ' +
+ 'LIMIT 1'
+
+ const options = {
+ type: QueryTypes.SELECT,
+ bind: { followerActorId, videoId },
+ raw: true
+ }
+
+ return VideoModel.sequelize.query(query, options)
+ .then(results => results.length === 1)
+ }
+
+ static bulkUpdateSupportField (videoChannel: VideoChannelModel, t: Transaction) {
+ const options = {
+ where: {
+ channelId: videoChannel.id
+ },
+ transaction: t
+ }
+
+ return VideoModel.update({ support: videoChannel.support }, options)
+ }
+
+ static getAllIdsFromChannel (videoChannel: VideoChannelModel) {
+ const query = {
+ attributes: [ 'id' ],
+ where: {
+ channelId: videoChannel.id
+ }
+ }
+
+ return VideoModel.findAll(query)
+ .then(videos => videos.map(v => v.id))
+ }
+