]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/user/sql/user-notitication-list-query-builder.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / user / sql / user-notitication-list-query-builder.ts
index 9eae4fc22cecbb1d0c7847c931d5557672927b27..31b4932bf47466c5d8159b8582d2defbe3978c90 100644 (file)
@@ -1,5 +1,5 @@
-import { QueryTypes, Sequelize } from 'sequelize'
-import { ModelBuilder } from '@server/models/shared'
+import { Sequelize } from 'sequelize'
+import { AbstractRunQuery, ModelBuilder } from '@server/models/shared'
 import { getSort } from '@server/models/utils'
 import { UserNotificationModelForApi } from '@server/types/models'
 import { ActorImageType } from '@shared/models'
@@ -10,28 +10,23 @@ export interface ListNotificationsOptions {
   sort: string
   offset: number
   limit: number
-  sequelize: Sequelize
 }
 
-export class UserNotificationListQueryBuilder {
+export class UserNotificationListQueryBuilder extends AbstractRunQuery {
   private innerQuery: string
-  private replacements: any = {}
-  private query: string
-
-  constructor (private readonly options: ListNotificationsOptions) {
 
+  constructor (
+    protected readonly sequelize: Sequelize,
+    private readonly options: ListNotificationsOptions
+  ) {
+    super(sequelize)
   }
 
   async listNotifications () {
     this.buildQuery()
 
-    const results = await this.options.sequelize.query(this.query, {
-      replacements: this.replacements,
-      type: QueryTypes.SELECT,
-      nest: true
-    })
-
-    const modelBuilder = new ModelBuilder<UserNotificationModelForApi>(this.options.sequelize)
+    const results = await this.runQuery({ nest: true })
+    const modelBuilder = new ModelBuilder<UserNotificationModelForApi>(this.sequelize)
 
     return modelBuilder.createModels(results, 'UserNotification')
   }
@@ -91,6 +86,7 @@ export class UserNotificationListQueryBuilder {
       "Video->VideoChannel->Actor"."preferredUsername" AS "Video.VideoChannel.Actor.preferredUsername",
       "Video->VideoChannel->Actor->Avatars"."id" AS "Video.VideoChannel.Actor.Avatars.id",
       "Video->VideoChannel->Actor->Avatars"."width" AS "Video.VideoChannel.Actor.Avatars.width",
+      "Video->VideoChannel->Actor->Avatars"."type" AS "Video.VideoChannel.Actor.Avatars.type",
       "Video->VideoChannel->Actor->Avatars"."filename" AS "Video.VideoChannel.Actor.Avatars.filename",
       "Video->VideoChannel->Actor->Server"."id" AS "Video.VideoChannel.Actor.Server.id",
       "Video->VideoChannel->Actor->Server"."host" AS "Video.VideoChannel.Actor.Server.host",
@@ -102,6 +98,7 @@ export class UserNotificationListQueryBuilder {
       "VideoComment->Account->Actor"."preferredUsername" AS "VideoComment.Account.Actor.preferredUsername",
       "VideoComment->Account->Actor->Avatars"."id" AS "VideoComment.Account.Actor.Avatars.id",
       "VideoComment->Account->Actor->Avatars"."width" AS "VideoComment.Account.Actor.Avatars.width",
+      "VideoComment->Account->Actor->Avatars"."type" AS "VideoComment.Account.Actor.Avatars.type",
       "VideoComment->Account->Actor->Avatars"."filename" AS "VideoComment.Account.Actor.Avatars.filename",
       "VideoComment->Account->Actor->Server"."id" AS "VideoComment.Account.Actor.Server.id",
       "VideoComment->Account->Actor->Server"."host" AS "VideoComment.Account.Actor.Server.host",
@@ -132,6 +129,7 @@ export class UserNotificationListQueryBuilder {
       "Abuse->FlaggedAccount->Actor"."preferredUsername" AS "Abuse.FlaggedAccount.Actor.preferredUsername",
       "Abuse->FlaggedAccount->Actor->Avatars"."id" AS "Abuse.FlaggedAccount.Actor.Avatars.id",
       "Abuse->FlaggedAccount->Actor->Avatars"."width" AS "Abuse.FlaggedAccount.Actor.Avatars.width",
+      "Abuse->FlaggedAccount->Actor->Avatars"."type" AS "Abuse.FlaggedAccount.Actor.Avatars.type",
       "Abuse->FlaggedAccount->Actor->Avatars"."filename" AS "Abuse.FlaggedAccount.Actor.Avatars.filename",
       "Abuse->FlaggedAccount->Actor->Server"."id" AS "Abuse.FlaggedAccount.Actor.Server.id",
       "Abuse->FlaggedAccount->Actor->Server"."host" AS "Abuse.FlaggedAccount.Actor.Server.host",
@@ -160,6 +158,7 @@ export class UserNotificationListQueryBuilder {
       "ActorFollow->ActorFollower->Account"."name" AS "ActorFollow.ActorFollower.Account.name",
       "ActorFollow->ActorFollower->Avatars"."id" AS "ActorFollow.ActorFollower.Avatars.id",
       "ActorFollow->ActorFollower->Avatars"."width" AS "ActorFollow.ActorFollower.Avatars.width",
+      "ActorFollow->ActorFollower->Avatars"."type" AS "ActorFollow.ActorFollower.Avatars.type",
       "ActorFollow->ActorFollower->Avatars"."filename" AS "ActorFollow.ActorFollower.Avatars.filename",
       "ActorFollow->ActorFollower->Server"."id" AS "ActorFollow.ActorFollower.Server.id",
       "ActorFollow->ActorFollower->Server"."host" AS "ActorFollow.ActorFollower.Server.host",
@@ -178,6 +177,7 @@ export class UserNotificationListQueryBuilder {
       "Account->Actor"."preferredUsername" AS "Account.Actor.preferredUsername",
       "Account->Actor->Avatars"."id" AS "Account.Actor.Avatars.id",
       "Account->Actor->Avatars"."width" AS "Account.Actor.Avatars.width",
+      "Account->Actor->Avatars"."type" AS "Account.Actor.Avatars.type",
       "Account->Actor->Avatars"."filename" AS "Account.Actor.Avatars.filename",
       "Account->Actor->Server"."id" AS "Account.Actor.Server.id",
       "Account->Actor->Server"."host" AS "Account.Actor.Server.host"`