Allow domain to be matched only once

This commit is contained in:
Rafał Kobyłko 2023-09-02 22:15:41 +02:00
parent e439029b2f
commit e7f447c185

View File

@ -80,6 +80,18 @@ internal class ServicesRepositoryImpl(
return
}
// Remove duplicates
val matchingServices = localData.selectAll().filter { it.assignedDomains.contains(domain.lowercase()) }
matchingServices.forEach { matched ->
localData.updateServiceSuspend(
matched.copy(
assignedDomains = matched.assignedDomains.minus(domain.lowercase()),
updatedAt = timeProvider.systemCurrentTime(),
)
)
}
localData.updateServiceSuspend(
service.copy(
assignedDomains = service.assignedDomains.plus(domain.lowercase()),