2023-07-31 07:34:36 -05:00
|
|
|
import { CONFIG } from '@server/initializers/config.js'
|
|
|
|
import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants.js'
|
|
|
|
import { ActorImageModel } from '@server/models/actor/actor-image.js'
|
|
|
|
import { MActorImage } from '@server/types/models/index.js'
|
|
|
|
import { AbstractPermanentFileCache } from './shared/index.js'
|
2023-06-06 08:59:51 -05:00
|
|
|
|
2023-06-07 01:53:14 -05:00
|
|
|
export class AvatarPermanentFileCache extends AbstractPermanentFileCache<MActorImage> {
|
2023-06-06 08:59:51 -05:00
|
|
|
|
|
|
|
constructor () {
|
2023-07-11 04:23:51 -05:00
|
|
|
super(CONFIG.STORAGE.ACTOR_IMAGES_DIR)
|
2023-06-06 08:59:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected loadModel (filename: string) {
|
2024-06-05 08:47:37 -05:00
|
|
|
return ActorImageModel.loadByFilename(filename)
|
2023-06-06 08:59:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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]
|
|
|
|
}
|
|
|
|
}
|