diff --git a/.env b/.env index e64c8ef6..5f4e78bc 100644 --- a/.env +++ b/.env @@ -166,10 +166,21 @@ MAIL_CONSUL_PREFER_IP=true MAIL_SMTP_HOST=smtp.world4you.com MAIL_SMTP_PORT=587 MAIL_SMTP_USER=online-nennen@mo-code.at -MAIL_SMTP_PASSWORD=secret +MAIL_SMTP_PASSWORD=Mogi#2reiten MAIL_SMTP_AUTH=true MAIL_SMTP_STARTTLS=true +SPRING_MAIL_HOST=localhost +SPRING_MAIL_PORT=1025 +SPRING_MAIL_USERNAME=online-nennen@mo-code.at +SPRING_MAIL_PASSWORD=dev +SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=false +SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=false +SPRING_CLOUD_CONSUL_DISCOVERY_ENABLED=false +SPRING_CLOUD_CONSUL_ENABLED=false +MAIL_POLLING_ENABLED=false + + # --- MASTERDATA-SERVICE --- MASTERDATA_PORT=8086:8086 MASTERDATA_DEBUG_PORT=5007:5007 diff --git a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailPollingService.kt b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailPollingService.kt index d1336679..5906b057 100644 --- a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailPollingService.kt +++ b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailPollingService.kt @@ -10,9 +10,9 @@ import jakarta.mail.Session import jakarta.mail.internet.InternetAddress import org.jetbrains.exposed.v1.jdbc.SchemaUtils import org.jetbrains.exposed.v1.jdbc.transactions.transaction -import org.springframework.transaction.annotation.Transactional import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener import org.springframework.mail.SimpleMailMessage @@ -20,6 +20,7 @@ import org.springframework.mail.javamail.JavaMailSender import org.springframework.scheduling.annotation.EnableScheduling import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.util.* import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @@ -27,6 +28,7 @@ import kotlin.uuid.Uuid @OptIn(ExperimentalUuidApi::class) @Service @EnableScheduling +@ConditionalOnProperty(value = ["mail.polling.enabled"], havingValue = "true", matchIfMissing = false) class MailPollingService( private val mailSender: JavaMailSender, private val nennungRepository: NennungRepository, diff --git a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/persistence/NennungRepository.kt b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/persistence/NennungRepository.kt index 618486ec..e9b54d8c 100644 --- a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/persistence/NennungRepository.kt +++ b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/persistence/NennungRepository.kt @@ -5,9 +5,9 @@ package at.mocode.mail.service.persistence import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.jdbc.insert import org.jetbrains.exposed.v1.jdbc.selectAll +import org.jetbrains.exposed.v1.jdbc.transactions.transaction import org.jetbrains.exposed.v1.jdbc.update import org.springframework.stereotype.Repository -import org.jetbrains.exposed.v1.jdbc.transactions.transaction import org.springframework.transaction.annotation.Transactional import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid diff --git a/backend/services/mail/mail-service/src/main/resources/application.yaml b/backend/services/mail/mail-service/src/main/resources/application.yaml index 7b2e4a9c..7e0299eb 100644 --- a/backend/services/mail/mail-service/src/main/resources/application.yaml +++ b/backend/services/mail/mail-service/src/main/resources/application.yaml @@ -44,3 +44,8 @@ management: web: exposure: include: "health,info,prometheus" + +# Feature-Flags +mail: + polling: + enabled: ${MAIL_POLLING_ENABLED:false} diff --git a/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/NennungViewModel.kt b/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/NennungViewModel.kt index 8001798b..dce2f67b 100644 --- a/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/NennungViewModel.kt +++ b/frontend/features/nennung-feature/src/commonMain/kotlin/at/mocode/frontend/features/nennung/presentation/NennungViewModel.kt @@ -1,9 +1,8 @@ package at.mocode.frontend.features.nennung.presentation -import at.mocode.frontend.features.nennung.domain.* import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.mocode.frontend.features.nennung.presentation.web.NennungDto +import at.mocode.frontend.features.nennung.domain.* import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.request.* @@ -50,6 +49,18 @@ class NennungViewModel : ViewModel(), KoinComponent { viewModelScope.launch { _uiState.update { it.copy(isOnlineLoading = true) } try { + // Lokales, schlankes DTO passend zur Backend-Response (MailController → NennungEntity) + data class NennungDto( + val id: String?, + val vorname: String, + val nachname: String, + val lizenz: String, + val pferdName: String, + val pferdAlter: String, + val email: String, + val bewerbe: String + ) + val dtos: List = apiClient.get("/api/mail/nennungen").body() val mapped = dtos.map { dto -> OnlineNennung(