]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user-notification.ts
Create a dedicated table to track video thumbnails
[github/Chocobozzz/PeerTube.git] / server / models / account / user-notification.ts
index 1094eec7883dd76238e0dfe4830b62084ecbc549..33480f3b585b205be6040623bcd3bb8dd7386aab 100644 (file)
@@ -28,6 +28,7 @@ import { VideoImportModel } from '../video/video-import'
 import { ActorModel } from '../activitypub/actor'
 import { ActorFollowModel } from '../activitypub/actor-follow'
 import { AvatarModel } from '../avatar/avatar'
+import { ServerModel } from '../server/server'
 
 enum ScopeNames {
   WITH_ALL = 'WITH_ALL'
@@ -43,6 +44,11 @@ function buildActorWithAvatarInclude () {
         attributes: [ 'filename' ],
         model: () => AvatarModel.unscoped(),
         required: false
+      },
+      {
+        attributes: [ 'host' ],
+        model: () => ServerModel.unscoped(),
+        required: false
       }
     ]
   }
@@ -113,7 +119,7 @@ function buildAccountInclude (required: boolean, withActor = false) {
       },
 
       {
-        attributes: [ 'id' ],
+        attributes: [ 'id', 'state' ],
         model: () => ActorFollowModel.unscoped(),
         required: false,
         include: [
@@ -132,6 +138,11 @@ function buildAccountInclude (required: boolean, withActor = false) {
                 attributes: [ 'filename' ],
                 model: () => AvatarModel.unscoped(),
                 required: false
+              },
+              {
+                attributes: [ 'host' ],
+                model: () => ServerModel.unscoped(),
+                required: false
               }
             ]
           },
@@ -407,11 +418,13 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
 
     const actorFollow = this.ActorFollow ? {
       id: this.ActorFollow.id,
+      state: this.ActorFollow.state,
       follower: {
         id: this.ActorFollow.ActorFollower.Account.id,
         displayName: this.ActorFollow.ActorFollower.Account.getDisplayName(),
         name: this.ActorFollow.ActorFollower.preferredUsername,
-        avatar: this.ActorFollow.ActorFollower.Avatar ? { path: this.ActorFollow.ActorFollower.Avatar.getWebserverPath() } : undefined
+        avatar: this.ActorFollow.ActorFollower.Avatar ? { path: this.ActorFollow.ActorFollower.Avatar.getWebserverPath() } : undefined,
+        host: this.ActorFollow.ActorFollower.getHost()
       },
       following: {
         type: this.ActorFollow.ActorFollowing.VideoChannel ? 'channel' as 'channel' : 'account' as 'account',
@@ -453,6 +466,7 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
       id: accountOrChannel.id,
       displayName: accountOrChannel.getDisplayName(),
       name: accountOrChannel.Actor.preferredUsername,
+      host: accountOrChannel.Actor.getHost(),
       avatar
     }
   }