aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/account-interface.ts2
-rw-r--r--server/models/account/account.ts17
-rw-r--r--server/models/video/video.ts35
3 files changed, 32 insertions, 22 deletions
diff --git a/server/models/account/account-interface.ts b/server/models/account/account-interface.ts
index 2e4b0382d..6fc98ba45 100644
--- a/server/models/account/account-interface.ts
+++ b/server/models/account/account-interface.ts
@@ -12,6 +12,7 @@ export namespace AccountMethods {
12 export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> 12 export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
13 export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> 13 export type LoadLocalByName = (name: string) => Bluebird<AccountInstance>
14 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> 14 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
15 export type ListByFollowersUrls = (followerUrls: string[], transaction?: Sequelize.Transaction) => Bluebird<AccountInstance[]>
15 16
16 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor 17 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
17 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount 18 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
@@ -29,6 +30,7 @@ export interface AccountClass {
29 loadByUrl: AccountMethods.LoadByUrl 30 loadByUrl: AccountMethods.LoadByUrl
30 loadLocalByName: AccountMethods.LoadLocalByName 31 loadLocalByName: AccountMethods.LoadLocalByName
31 loadByNameAndHost: AccountMethods.LoadByNameAndHost 32 loadByNameAndHost: AccountMethods.LoadByNameAndHost
33 listByFollowersUrls: AccountMethods.ListByFollowersUrls
32} 34}
33 35
34export interface AccountAttributes { 36export interface AccountAttributes {
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index f2bd325f3..fff3ce087 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -26,6 +26,7 @@ let loadByUUID: AccountMethods.LoadByUUID
26let loadByUrl: AccountMethods.LoadByUrl 26let loadByUrl: AccountMethods.LoadByUrl
27let loadLocalByName: AccountMethods.LoadLocalByName 27let loadLocalByName: AccountMethods.LoadLocalByName
28let loadByNameAndHost: AccountMethods.LoadByNameAndHost 28let loadByNameAndHost: AccountMethods.LoadByNameAndHost
29let listByFollowersUrls: AccountMethods.ListByFollowersUrls
29let isOwned: AccountMethods.IsOwned 30let isOwned: AccountMethods.IsOwned
30let toActivityPubObject: AccountMethods.ToActivityPubObject 31let toActivityPubObject: AccountMethods.ToActivityPubObject
31let toFormattedJSON: AccountMethods.ToFormattedJSON 32let toFormattedJSON: AccountMethods.ToFormattedJSON
@@ -188,7 +189,8 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
188 loadByUUID, 189 loadByUUID,
189 loadByUrl, 190 loadByUrl,
190 loadLocalByName, 191 loadLocalByName,
191 loadByNameAndHost 192 loadByNameAndHost,
193 listByFollowersUrls
192 ] 194 ]
193 const instanceMethods = [ 195 const instanceMethods = [
194 isOwned, 196 isOwned,
@@ -427,3 +429,16 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) {
427 429
428 return Account.findOne(query) 430 return Account.findOne(query)
429} 431}
432
433listByFollowersUrls = function (followersUrls: string[], transaction?: Sequelize.Transaction) {
434 const query: Sequelize.FindOptions<AccountAttributes> = {
435 where: {
436 followersUrl: {
437 [Sequelize.Op.in]: followersUrls
438 }
439 },
440 transaction
441 }
442
443 return Account.findAll(query)
444}
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index e5fd92549..82b95c489 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -6,27 +6,8 @@ import { join } from 'path'
6import * as Sequelize from 'sequelize' 6import * as Sequelize from 'sequelize'
7import { VideoPrivacy, VideoResolution } from '../../../shared' 7import { VideoPrivacy, VideoResolution } from '../../../shared'
8import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' 8import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
9import {
10 createTorrentPromise,
11 generateImageFromVideoFile,
12 getVideoFileHeight,
13 isVideoCategoryValid,
14 isVideoDescriptionValid,
15 isVideoDurationValid,
16 isVideoLanguageValid,
17 isVideoLicenceValid,
18 isVideoNameValid,
19 isVideoNSFWValid,
20 isVideoPrivacyValid,
21 logger,
22 renamePromise,
23 statPromise,
24 transcode,
25 unlinkPromise,
26 writeFilePromise
27} from '../../helpers'
28import { activityPubCollection } from '../../helpers/activitypub' 9import { activityPubCollection } from '../../helpers/activitypub'
29import { isVideoUrlValid } from '../../helpers/custom-validators/videos' 10import { isVideoCategoryValid, isVideoLanguageValid, isVideoPrivacyValid, isVideoUrlValid } from '../../helpers/custom-validators/videos'
30import { 11import {
31 API_VERSION, 12 API_VERSION,
32 CONFIG, 13 CONFIG,
@@ -39,7 +20,7 @@ import {
39 VIDEO_LANGUAGES, 20 VIDEO_LANGUAGES,
40 VIDEO_LICENCES, 21 VIDEO_LICENCES,
41 VIDEO_PRIVACIES 22 VIDEO_PRIVACIES
42} from '../../initializers' 23} from '../../initializers/constants'
43import { sendDeleteVideo } from '../../lib/index' 24import { sendDeleteVideo } from '../../lib/index'
44 25
45import { addMethodsToModel, getSort } from '../utils' 26import { addMethodsToModel, getSort } from '../utils'
@@ -47,6 +28,10 @@ import { addMethodsToModel, getSort } from '../utils'
47import { TagInstance } from './tag-interface' 28import { TagInstance } from './tag-interface'
48import { VideoFileInstance, VideoFileModel } from './video-file-interface' 29import { VideoFileInstance, VideoFileModel } from './video-file-interface'
49import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' 30import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface'
31import { isVideoNameValid, isVideoLicenceValid, isVideoNSFWValid, isVideoDescriptionValid, isVideoDurationValid } from '../../helpers/index'
32import { logger } from '../../helpers/logger'
33import { generateImageFromVideoFile, transcode, getVideoFileHeight } from '../../helpers/ffmpeg-utils'
34import { createTorrentPromise, writeFilePromise, unlinkPromise, renamePromise, statPromise } from '../../helpers/core-utils'
50 35
51let Video: Sequelize.Model<VideoInstance, VideoAttributes> 36let Video: Sequelize.Model<VideoInstance, VideoAttributes>
52let getOriginalFile: VideoMethods.GetOriginalFile 37let getOriginalFile: VideoMethods.GetOriginalFile
@@ -1013,6 +998,10 @@ loadAndPopulateAccountAndServerAndTags = function (id: number) {
1013 model: Video['sequelize'].models.AccountVideoRate, 998 model: Video['sequelize'].models.AccountVideoRate,
1014 include: [ Video['sequelize'].models.Account ] 999 include: [ Video['sequelize'].models.Account ]
1015 }, 1000 },
1001 {
1002 model: Video['sequelize'].models.VideoShare,
1003 include: [ Video['sequelize'].models.Account ]
1004 },
1016 Video['sequelize'].models.Tag, 1005 Video['sequelize'].models.Tag,
1017 Video['sequelize'].models.VideoFile 1006 Video['sequelize'].models.VideoFile
1018 ] 1007 ]
@@ -1040,6 +1029,10 @@ loadByUUIDAndPopulateAccountAndServerAndTags = function (uuid: string) {
1040 model: Video['sequelize'].models.AccountVideoRate, 1029 model: Video['sequelize'].models.AccountVideoRate,
1041 include: [ Video['sequelize'].models.Account ] 1030 include: [ Video['sequelize'].models.Account ]
1042 }, 1031 },
1032 {
1033 model: Video['sequelize'].models.VideoShare,
1034 include: [ Video['sequelize'].models.Account ]
1035 },
1043 Video['sequelize'].models.Tag, 1036 Video['sequelize'].models.Tag,
1044 Video['sequelize'].models.VideoFile 1037 Video['sequelize'].models.VideoFile
1045 ] 1038 ]