From 84531547bc0934a2abda586d539f7455b455d488 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Apr 2021 11:23:45 +0200 Subject: Add size info in db for actor images --- server/models/account/actor-image.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/actor-image.ts b/server/models/account/actor-image.ts index f7438991a..ae05b4969 100644 --- a/server/models/account/actor-image.ts +++ b/server/models/account/actor-image.ts @@ -1,7 +1,6 @@ import { remove } from 'fs-extra' import { join } from 'path' -import { AfterDestroy, AllowNull, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { v4 as uuidv4 } from 'uuid' +import { AfterDestroy, AllowNull, Column, CreatedAt, Default, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { MActorImageFormattable } from '@server/types/models' import { ActorImageType } from '@shared/models' import { ActorImage } from '../../../shared/models/actors/actor-image.model' @@ -26,6 +25,16 @@ export class ActorImageModel extends Model { @Column filename: string + @AllowNull(true) + @Default(null) + @Column + height: number + + @AllowNull(true) + @Default(null) + @Column + width: number + @AllowNull(true) @Is('ActorImageFileUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'fileUrl', true)) @Column @@ -54,10 +63,6 @@ export class ActorImageModel extends Model { .catch(err => logger.error('Cannot remove actor image file %s.', instance.filename, err)) } - static generateFilename () { - return uuidv4() + '.jpg' - } - static loadByName (filename: string) { const query = { where: { -- cgit v1.2.3