]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-abuse.ts
Fix max buffer reached in youtube import
[github/Chocobozzz/PeerTube.git] / server / models / video / video-abuse.ts
index d0ee969fb10c89f13fdba06c1cd880c9ce60507c..cc7078ae7966541ecea1c3bb79a542af19fc178c 100644 (file)
@@ -1,9 +1,9 @@
-import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
+import { AfterCreate, AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
 import { VideoAbuseObject } from '../../../shared/models/activitypub/objects'
 import { isVideoAbuseReasonValid } from '../../helpers/custom-validators/videos'
 import { CONFIG } from '../../initializers'
+import { Emailer } from '../../lib/emailer'
 import { AccountModel } from '../account/account'
-import { ServerModel } from '../server/server'
 import { getSort, throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
 
@@ -55,6 +55,11 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
   })
   Video: VideoModel
 
+  @AfterCreate
+  static sendEmailNotification (instance: VideoAbuseModel) {
+    return Emailer.Instance.addVideoAbuseReport(instance.videoId)
+  }
+
   static listForApi (start: number, count: number, sort: string) {
     const query = {
       offset: start,
@@ -63,13 +68,7 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
       include: [
         {
           model: AccountModel,
-          required: true,
-          include: [
-            {
-              model: ServerModel,
-              required: false
-            }
-          ]
+          required: true
         },
         {
           model: VideoModel,
@@ -87,8 +86,8 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
   toFormattedJSON () {
     let reporterServerHost
 
-    if (this.Account.Server) {
-      reporterServerHost = this.Account.Server.host
+    if (this.Account.Actor.Server) {
+      reporterServerHost = this.Account.Actor.Server.host
     } else {
       // It means it's our video
       reporterServerHost = CONFIG.WEBSERVER.HOST