diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 17:04:19 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 21e0727a84734cb0c81c1c9bb22a49b13e46fe5f (patch) | |
tree | 088da51cadbffe3ac64414b407e161f58b53bde7 /server/models/video/video-abuse.ts | |
parent | d7d5611c8a23de9b483f0437ad3469afef7b8805 (diff) | |
download | PeerTube-21e0727a84734cb0c81c1c9bb22a49b13e46fe5f.tar.gz PeerTube-21e0727a84734cb0c81c1c9bb22a49b13e46fe5f.tar.zst PeerTube-21e0727a84734cb0c81c1c9bb22a49b13e46fe5f.zip |
Federate video abuses
Diffstat (limited to 'server/models/video/video-abuse.ts')
-rw-r--r-- | server/models/video/video-abuse.ts | 15 |
1 files changed, 14 insertions, 1 deletions
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' |
13 | import { VideoAbuseObject } from '../../../shared/models/activitypub/objects/video-abuse-object' | ||
13 | 14 | ||
14 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> | 15 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> |
15 | let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON | 16 | let toFormattedJSON: VideoAbuseMethods.ToFormattedJSON |
16 | let listForApi: VideoAbuseMethods.ListForApi | 17 | let listForApi: VideoAbuseMethods.ListForApi |
18 | let toActivityPubObject: VideoAbuseMethods.ToActivityPubObject | ||
17 | 19 | ||
18 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 20 | export 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 | ||
86 | toActivityPubObject = 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 | ||
85 | function associate (models) { | 98 | function associate (models) { |