]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/actor/actor-image.ts
Support studio transcoding in peertube runner
[github/Chocobozzz/PeerTube.git] / server / models / actor / actor-image.ts
index f74ab735e31717d5e0a9f04069a487376fb4bf04..9c34a0101acf46c778f548933f7ed924d756d5a0 100644 (file)
@@ -22,7 +22,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
 import { logger } from '../../helpers/logger'
 import { CONFIG } from '../../initializers/config'
 import { LAZY_STATIC_PATHS, MIMETYPES, WEBSERVER } from '../../initializers/constants'
-import { throwIfNotValid } from '../utils'
+import { buildSQLAttributes, throwIfNotValid } from '../shared'
 import { ActorModel } from './actor'
 
 @Table({
@@ -91,9 +91,21 @@ export class ActorImageModel extends Model<Partial<AttributesOnly<ActorImageMode
 
     // Don't block the transaction
     instance.removeImage()
-      .catch(err => logger.error('Cannot remove actor image file %s.', instance.filename, err))
+      .catch(err => logger.error('Cannot remove actor image file %s.', instance.filename, { err }))
   }
 
+  // ---------------------------------------------------------------------------
+
+  static getSQLAttributes (tableName: string, aliasPrefix = '') {
+    return buildSQLAttributes({
+      model: this,
+      tableName,
+      aliasPrefix
+    })
+  }
+
+  // ---------------------------------------------------------------------------
+
   static loadByName (filename: string) {
     const query = {
       where: {
@@ -138,6 +150,9 @@ export class ActorImageModel extends Model<Partial<AttributesOnly<ActorImageMode
 
       case ActorImageType.BANNER:
         return join(LAZY_STATIC_PATHS.BANNERS, this.filename)
+
+      default:
+        throw new Error('Unknown actor image type: ' + this.type)
     }
   }