in api/src/main/scala/com/gu/core/store/store.scala [309:327]
private[this] def deleteAvatarKvEntries(avatarIds: List[String]): Either[Error, DeleteResponse] = kvs.delete(dynamoTable, avatarIds)
private[this] def deleteActiveAvatar(userId: String): Either[Error, DeleteResult] = {
def delete(avatar: Avatar) = {
val buckets = List(incomingBucket, rawBucket, processedBucket)
for {
locations <- deleteAvatars(buckets, List(avatar.id))
publicImage <- deletePublicAvatarFile(avatar.userId)
} yield {
AvatarDeleted(avatar, publicImage :: locations)
}
}
getActive(User(userId)).map(_.body) match {
case Right(avatar) => delete(avatar)
case Left(AvatarNotFound(_, _)) => Right(AvatarNotDeleted(userId))
case Left(e: Error) => Left(e)
}
}