### feat: verbessere DTO-Handling und füge Feature-Flag hinzu

- **NennungViewModel:** Definiere lokales `NennungDto` zur Optimierung der Backend-Response-Verarbeitung.
- **MailPollingService:** Ergänze Bedingung für Scheduler-Aktivierung (`ConditionalOnProperty`).
- **.env & application.yaml:** Füge `MAIL_POLLING_ENABLED` als Feature-Flag hinzu.
- **Dependencies:** Refaktor Import-Reihenfolge für Konsistenz.
This commit is contained in:
Stefan Mogeritsch 2026-04-22 20:26:59 +02:00
parent 8b44edda90
commit 309834d90c
5 changed files with 34 additions and 5 deletions

13
.env
View File

@ -166,10 +166,21 @@ MAIL_CONSUL_PREFER_IP=true
MAIL_SMTP_HOST=smtp.world4you.com MAIL_SMTP_HOST=smtp.world4you.com
MAIL_SMTP_PORT=587 MAIL_SMTP_PORT=587
MAIL_SMTP_USER=online-nennen@mo-code.at MAIL_SMTP_USER=online-nennen@mo-code.at
MAIL_SMTP_PASSWORD=secret MAIL_SMTP_PASSWORD=Mogi#2reiten
MAIL_SMTP_AUTH=true MAIL_SMTP_AUTH=true
MAIL_SMTP_STARTTLS=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-SERVICE ---
MASTERDATA_PORT=8086:8086 MASTERDATA_PORT=8086:8086
MASTERDATA_DEBUG_PORT=5007:5007 MASTERDATA_DEBUG_PORT=5007:5007

View File

@ -10,9 +10,9 @@ import jakarta.mail.Session
import jakarta.mail.internet.InternetAddress import jakarta.mail.internet.InternetAddress
import org.jetbrains.exposed.v1.jdbc.SchemaUtils import org.jetbrains.exposed.v1.jdbc.SchemaUtils
import org.jetbrains.exposed.v1.jdbc.transactions.transaction import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import org.springframework.transaction.annotation.Transactional
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.event.EventListener import org.springframework.context.event.EventListener
import org.springframework.mail.SimpleMailMessage 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.EnableScheduling
import org.springframework.scheduling.annotation.Scheduled import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.util.* import java.util.*
import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid import kotlin.uuid.Uuid
@ -27,6 +28,7 @@ import kotlin.uuid.Uuid
@OptIn(ExperimentalUuidApi::class) @OptIn(ExperimentalUuidApi::class)
@Service @Service
@EnableScheduling @EnableScheduling
@ConditionalOnProperty(value = ["mail.polling.enabled"], havingValue = "true", matchIfMissing = false)
class MailPollingService( class MailPollingService(
private val mailSender: JavaMailSender, private val mailSender: JavaMailSender,
private val nennungRepository: NennungRepository, private val nennungRepository: NennungRepository,

View File

@ -5,9 +5,9 @@ package at.mocode.mail.service.persistence
import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.jdbc.insert import org.jetbrains.exposed.v1.jdbc.insert
import org.jetbrains.exposed.v1.jdbc.selectAll import org.jetbrains.exposed.v1.jdbc.selectAll
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import org.jetbrains.exposed.v1.jdbc.update import org.jetbrains.exposed.v1.jdbc.update
import org.springframework.stereotype.Repository import org.springframework.stereotype.Repository
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.annotation.Transactional
import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid import kotlin.uuid.Uuid

View File

@ -44,3 +44,8 @@ management:
web: web:
exposure: exposure:
include: "health,info,prometheus" include: "health,info,prometheus"
# Feature-Flags
mail:
polling:
enabled: ${MAIL_POLLING_ENABLED:false}

View File

@ -1,9 +1,8 @@
package at.mocode.frontend.features.nennung.presentation package at.mocode.frontend.features.nennung.presentation
import at.mocode.frontend.features.nennung.domain.*
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope 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.*
import io.ktor.client.call.* import io.ktor.client.call.*
import io.ktor.client.request.* import io.ktor.client.request.*
@ -50,6 +49,18 @@ class NennungViewModel : ViewModel(), KoinComponent {
viewModelScope.launch { viewModelScope.launch {
_uiState.update { it.copy(isOnlineLoading = true) } _uiState.update { it.copy(isOnlineLoading = true) }
try { 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<NennungDto> = apiClient.get("/api/mail/nennungen").body() val dtos: List<NennungDto> = apiClient.get("/api/mail/nennungen").body()
val mapped = dtos.map { dto -> val mapped = dtos.map { dto ->
OnlineNennung( OnlineNennung(