]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/actor/actor.ts
Translated using Weblate (Ukrainian)
[github/Chocobozzz/PeerTube.git] / server / models / actor / actor.ts
index 5cf6fb8f16810dc3b5692a9023847246c9037211..8df49951d561ce66743f72c17f6260e442fccb97 100644 (file)
@@ -1,5 +1,4 @@
 import { values } from 'lodash'
-import { extname } from 'path'
 import { literal, Op, Transaction } from 'sequelize'
 import {
   AllowNull,
@@ -17,7 +16,9 @@ import {
   Table,
   UpdatedAt
 } from 'sequelize-typescript'
+import { getLowercaseExtension } from '@server/helpers/core-utils'
 import { ModelCache } from '@server/models/model-cache'
+import { AttributesOnly } from '@shared/core-utils'
 import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub'
 import { ActorImage } from '../../../shared/models/actors/actor-image.model'
 import { activityPubContextify } from '../../helpers/activitypub'
@@ -159,7 +160,7 @@ export const unusedActorAttributesForAPI = [
     }
   ]
 })
-export class ActorModel extends Model {
+export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
 
   @AllowNull(false)
   @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES)))
@@ -495,7 +496,7 @@ export class ActorModel extends Model {
     }, { where, transaction })
   }
 
-  static loadAccountActorByVideoId (videoId: number): Promise<MActor> {
+  static loadAccountActorByVideoId (videoId: number, transaction: Transaction): Promise<MActor> {
     const query = {
       include: [
         {
@@ -519,7 +520,8 @@ export class ActorModel extends Model {
             }
           ]
         }
-      ]
+      ],
+      transaction
     }
 
     return ActorModel.unscoped().findOne(query)
@@ -566,7 +568,7 @@ export class ActorModel extends Model {
     let image: ActivityIconObject
 
     if (this.avatarId) {
-      const extension = extname(this.Avatar.filename)
+      const extension = getLowercaseExtension(this.Avatar.filename)
 
       icon = {
         type: 'Image',
@@ -579,7 +581,7 @@ export class ActorModel extends Model {
 
     if (this.bannerId) {
       const banner = (this as MActorAPChannel).Banner
-      const extension = extname(banner.filename)
+      const extension = getLowercaseExtension(banner.filename)
 
       image = {
         type: 'Image',