diff --git a/backend/src/main/java/com/paligot/confily/backend/partners/PartnerModule.kt b/backend/src/main/java/com/paligot/confily/backend/partners/PartnerModule.kt index 7ae69e2c1..8470c02c6 100644 --- a/backend/src/main/java/com/paligot/confily/backend/partners/PartnerModule.kt +++ b/backend/src/main/java/com/paligot/confily/backend/partners/PartnerModule.kt @@ -3,6 +3,7 @@ package com.paligot.confily.backend.partners import com.paligot.confily.backend.activities.ActivityModule.activityDao import com.paligot.confily.backend.events.EventModule.eventDao import com.paligot.confily.backend.internals.GoogleServicesModule.cloudFirestore +import com.paligot.confily.backend.internals.InternalModule.commonApi import com.paligot.confily.backend.internals.InternalModule.storage import com.paligot.confily.backend.internals.InternalModule.transcoder import com.paligot.confily.backend.internals.SystemEnv.projectName @@ -14,6 +15,7 @@ object PartnerModule { val partnerRepository = lazy { PartnerRepository( geocodeApi.value, + commonApi.value, eventDao.value, partnerDao.value, activityDao.value, diff --git a/backend/src/main/java/com/paligot/confily/backend/partners/PartnerRepository.kt b/backend/src/main/java/com/paligot/confily/backend/partners/PartnerRepository.kt index 20822a768..a05b9cecf 100644 --- a/backend/src/main/java/com/paligot/confily/backend/partners/PartnerRepository.kt +++ b/backend/src/main/java/com/paligot/confily/backend/partners/PartnerRepository.kt @@ -5,6 +5,8 @@ import com.paligot.confily.backend.NotFoundException import com.paligot.confily.backend.activities.ActivityDao import com.paligot.confily.backend.activities.convertToModel import com.paligot.confily.backend.events.EventDao +import com.paligot.confily.backend.internals.CommonApi +import com.paligot.confily.backend.internals.helpers.image.Png import com.paligot.confily.backend.internals.helpers.image.TranscoderImage import com.paligot.confily.backend.jobs.JobDao import com.paligot.confily.backend.third.parties.geocode.GeocodeApi @@ -22,6 +24,7 @@ import kotlinx.coroutines.coroutineScope @Suppress("LongParameterList") class PartnerRepository( private val geocodeApi: GeocodeApi, + private val commonApi: CommonApi, private val eventDao: EventDao, private val partnerDao: PartnerDao, private val activityDao: ActivityDao, @@ -77,11 +80,20 @@ class PartnerRepository( ?: throw NotAcceptableException("Your address information isn't found") val partnerDb = partnerInput.convertToDb(addressDb = addressDb) val id = partnerDao.createOrUpdate(eventId, partnerDb) - val pngs = listOf( - async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_250) }, - async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_500) }, - async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_1000) } - ).awaitAll() + val pngs = if (partnerInput.logoUrl.endsWith(".png")) { + val content = commonApi.fetchByteArray(partnerInput.logoUrl) + listOf( + Png(content = content, size = 250), + Png(content = content, size = 500), + Png(content = content, size = 1000) + ) + } else { + listOf( + async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_250) }, + async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_500) }, + async { imageTranscoder.convertSvgToPng(partnerInput.logoUrl, SIZE_1000) } + ).awaitAll() + } val uploads = partnerDao.uploadPartnerLogos(eventId, id, pngs) partnerDao.createOrUpdate( eventId,