2023-06-07 01:53:14 -05:00
|
|
|
import { CONFIG } from '@server/initializers/config'
|
2023-06-06 08:59:51 -05:00
|
|
|
import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
|
|
|
|
import { ActorImageModel } from '@server/models/actor/actor-image'
|
|
|
|
import { MActorImage } from '@server/types/models'
|
|
|
|
import { AbstractPermanentFileCache } from './shared'
|
|
|
|
|
2023-06-07 01:53:14 -05:00
|
|
|
export class AvatarPermanentFileCache extends AbstractPermanentFileCache<MActorImage> {
|
2023-06-06 08:59:51 -05:00
|
|
|
|
|
|
|
constructor () {
|
|
|
|
super(CONFIG.STORAGE.ACTOR_IMAGES)
|
|
|
|
}
|
|
|
|
|
|
|
|
protected loadModel (filename: string) {
|
|
|
|
return ActorImageModel.loadByName(filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getImageSize (image: MActorImage): { width: number, height: number } {
|
|
|
|
if (image.width && image.height) {
|
|
|
|
return {
|
|
|
|
height: image.height,
|
|
|
|
width: image.width
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ACTOR_IMAGES_SIZE[image.type][0]
|
|
|
|
}
|
|
|
|
}
|