- const imageName = uuidv4() + extension
- const destination = join(CONFIG.STORAGE.ACTOR_IMAGES, imageName)
- await processImage(imagePhysicalFile.path, destination, imageSize)
-
- return retryTransactionWrapper(() => {
- return sequelizeTypescript.transaction(async t => {
- const actorImageInfo = {
- name: imageName,
- fileUrl: null,
- height: imageSize.height,
- width: imageSize.width,
- onDisk: true
- }
-
- const updatedActor = await updateActorImageInstance(accountOrChannel.Actor, type, actorImageInfo, t)
- await updatedActor.save({ transaction: t })
-
- await sendUpdateActor(accountOrChannel, t)
-
- return type === ActorImageType.AVATAR
- ? updatedActor.Avatar
- : updatedActor.Banner
- })
- })
-}
-
-async function deleteLocalActorImageFile (accountOrChannel: MAccountDefault | MChannelDefault, type: ActorImageType) {
- return retryTransactionWrapper(() => {
- return sequelizeTypescript.transaction(async t => {
- const updatedActor = await deleteActorImageInstance(accountOrChannel.Actor, type, t)
- await updatedActor.save({ transaction: t })
-
- await sendUpdateActor(accountOrChannel, t)
-
- return updatedActor.Avatar
- })
- })