type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string }
async function updateActorAvatarInstance (actor: MActorDefault, info: AvatarInfo, t: Transaction) {
type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string }
async function updateActorAvatarInstance (actor: MActorDefault, info: AvatarInfo, t: Transaction) {
- if (info.name !== undefined) {
- if (actor.avatarId) {
- try {
- await actor.Avatar.destroy({ transaction: t })
- } catch (err) {
- logger.error('Cannot remove old avatar of actor %s.', actor.url, { err })
- }
- }
+ if (!info.name) return actor