aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-abuse-interface.ts3
-rw-r--r--server/models/video/video-abuse.ts15
-rw-r--r--server/models/video/video.ts4
3 files changed, 19 insertions, 3 deletions
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts
index 96f0fbe4a..feafc4a19 100644
--- a/server/models/video/video-abuse-interface.ts
+++ b/server/models/video/video-abuse-interface.ts
@@ -5,15 +5,18 @@ import { VideoAbuse as FormattedVideoAbuse } from '../../../shared/models/videos
5import { AccountInstance } from '../account/account-interface' 5import { AccountInstance } from '../account/account-interface'
6import { ServerInstance } from '../server/server-interface' 6import { ServerInstance } from '../server/server-interface'
7import { VideoInstance } from './video-interface' 7import { VideoInstance } from './video-interface'
8import { VideoAbuseObject } from '../../../shared/models/activitypub/objects/video-abuse-object'
8 9
9export namespace VideoAbuseMethods { 10export namespace VideoAbuseMethods {
10 export type ToFormattedJSON = (this: VideoAbuseInstance) => FormattedVideoAbuse 11 export type ToFormattedJSON = (this: VideoAbuseInstance) => FormattedVideoAbuse
11 12
12 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoAbuseInstance> > 13 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoAbuseInstance> >
14 export type ToActivityPubObject = () => VideoAbuseObject
13} 15}
14 16
15export interface VideoAbuseClass { 17export interface VideoAbuseClass {
16 listForApi: VideoAbuseMethods.ListForApi 18 listForApi: VideoAbuseMethods.ListForApi
19 toActivityPubObject: VideoAbuseMethods.ToActivityPubObject
17} 20}
18 21
19export interface VideoAbuseAttributes { 22export interface VideoAbuseAttributes {
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts
index f3fdeab52..e8f4f9a67 100644
--- a/server/models/video/video-abuse.ts
+++ b/server/models/video/video-abuse.ts
@@ -10,10 +10,12 @@ import {
10 10
11 VideoAbuseMethods 11 VideoAbuseMethods
12} from './video-abuse-interface' 12} from './video-abuse-interface'
13import { VideoAbuseObject } from '../../../shared/models/activitypub/objects/video-abuse-object'
13 14
14let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> 15let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
15let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON 16let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON
16let listForApi: VideoAbuseMethods.ListForApi 17let listForApi: VideoAbuseMethods.ListForApi
18let toActivityPubObject: VideoAbuseMethods.ToActivityPubObject
17 19
18export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { 20export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
19 VideoAbuse = sequelize.define<VideoAbuseInstance, VideoAbuseAttributes>('VideoAbuse', 21 VideoAbuse = sequelize.define<VideoAbuseInstance, VideoAbuseAttributes>('VideoAbuse',
@@ -47,7 +49,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
47 listForApi 49 listForApi
48 ] 50 ]
49 const instanceMethods = [ 51 const instanceMethods = [
50 toFormattedJSON 52 toFormattedJSON,
53 toActivityPubObject
51 ] 54 ]
52 addMethodsToModel(VideoAbuse, classMethods, instanceMethods) 55 addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
53 56
@@ -80,6 +83,16 @@ toFormattedJSON = function (this: VideoAbuseInstance) {
80 return json 83 return json
81} 84}
82 85
86toActivityPubObject = function (this: VideoAbuseInstance) {
87 const videoAbuseObject: VideoAbuseObject = {
88 type: 'Flag' as 'Flag',
89 content: this.reason,
90 object: this.Video.url
91 }
92
93 return videoAbuseObject
94}
95
83// ------------------------------ STATICS ------------------------------ 96// ------------------------------ STATICS ------------------------------
84 97
85function associate (models) { 98function associate (models) {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 5b0377c2e..5fb254b2d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -26,6 +26,7 @@ import {
26 unlinkPromise, 26 unlinkPromise,
27 writeFilePromise 27 writeFilePromise
28} from '../../helpers' 28} from '../../helpers'
29import { isVideoUrlValid } from '../../helpers/custom-validators/videos'
29import { 30import {
30 API_VERSION, 31 API_VERSION,
31 CONFIG, 32 CONFIG,
@@ -39,14 +40,13 @@ import {
39 VIDEO_LICENCES, 40 VIDEO_LICENCES,
40 VIDEO_PRIVACIES 41 VIDEO_PRIVACIES
41} from '../../initializers' 42} from '../../initializers'
43import { sendDeleteVideo } from '../../lib/activitypub/send-request'
42 44
43import { addMethodsToModel, getSort } from '../utils' 45import { addMethodsToModel, getSort } from '../utils'
44 46
45import { TagInstance } from './tag-interface' 47import { TagInstance } from './tag-interface'
46import { VideoFileInstance, VideoFileModel } from './video-file-interface' 48import { VideoFileInstance, VideoFileModel } from './video-file-interface'
47import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface' 49import { VideoAttributes, VideoInstance, VideoMethods } from './video-interface'
48import { sendDeleteVideo } from '../../lib/activitypub/send-request'
49import { isVideoUrlValid } from '../../helpers/custom-validators/videos'
50 50
51const Buffer = safeBuffer.Buffer 51const Buffer = safeBuffer.Buffer
52 52