Коммит 59d6e45b создал по автору Radch-enko's avatar Radch-enko
Просмотр файлов

Remove outdated files, enhance logging, and update configurations

- Deleted `network_security_config.xml` and removed its reference from `AndroidManifest.xml` to simplify project structure.
- Enhanced logging in `CalendarSubscriptionScheduler` for better debugging of calendar subscriptions.
- Improved resource management in `RootComponent` with `ResourceDisposerUseCase` integration and memory leak prevention.
- Adjusted `docker-compose.yml` configurations for better resilience and dynamic environments.
- Refactored `ResourceDisposerUseCase` to allow reinitialization and prevent unused job persistence.
- Simplified message handling in `ServerMessagingService` to avoid unnecessary data conversion.
владелец aaaf1517
...@@ -81,6 +81,6 @@ calendar: ...@@ -81,6 +81,6 @@ calendar:
google-credentials: ${GOOGLE_CREDENTIALS_FILE:classpath:google-credentials.json} google-credentials: ${GOOGLE_CREDENTIALS_FILE:classpath:google-credentials.json}
application-url: ${APPLICATION_URL} application-url: ${APPLICATION_URL}
test-application-url: ${TEST_APPLICATION_URL} test-application-url: ${TEST_APPLICATION_URL}
calendars: ${CALENDARS:} calendars: ${CALENDARS}
test-calendars: ${TEST_CALENDARS} test-calendars: ${TEST_CALENDARS}
firebase-credentials: ${FIREBASE_CREDENTIALS:classpath:firebase-credentials.json} firebase-credentials: ${FIREBASE_CREDENTIALS:classpath:firebase-credentials.json}
\ No newline at end of file
...@@ -9,7 +9,7 @@ services: ...@@ -9,7 +9,7 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
environment: environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/${POSTGRES_DB} - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/effectiveoffice
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER} - SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD} - SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}
depends_on: depends_on:
...@@ -17,7 +17,7 @@ services: ...@@ -17,7 +17,7 @@ services:
condition: service_healthy condition: service_healthy
networks: networks:
- effective-office-network - effective-office-network
restart: no restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"] test: ["CMD", "curl", "-f", "http://localhost:8080/api/actuator/health"]
interval: 30s interval: 30s
...@@ -31,15 +31,14 @@ services: ...@@ -31,15 +31,14 @@ services:
ports: ports:
- "5432:5432" - "5432:5432"
environment: environment:
POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_DB=${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_USER=${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes: volumes:
- postgres-data:/var/lib/postgresql/data - postgres-data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
networks: networks:
- effective-office-network - effective-office-network
restart: no restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"] test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s interval: 10s
......
...@@ -298,7 +298,6 @@ class GoogleCalendarProvider( ...@@ -298,7 +298,6 @@ class GoogleCalendarProvider(
private fun convertToBooking(event: Event): Booking { private fun convertToBooking(event: Event): Booking {
// Get the organizer's email and find the corresponding user // Get the organizer's email and find the corresponding user
logger.debug("event.organizer?.email: ${event.organizer?.email}")
val organizer = event?.organizer?.email val organizer = event?.organizer?.email
// Check if the user found by organizer email is a system user // Check if the user found by organizer email is a system user
......
...@@ -30,6 +30,8 @@ class CalendarSubscriptionScheduler( ...@@ -30,6 +30,8 @@ class CalendarSubscriptionScheduler(
// Subscribe to production calendars // Subscribe to production calendars
val productionCalendars = config.getCalendars() val productionCalendars = config.getCalendars()
logger.debug("productionCalendars: {}", productionCalendars)
logger.debug("applicationUrl: {}", config.applicationUrl)
if (config.applicationUrl.isNotBlank() && productionCalendars.isNotEmpty()) { if (config.applicationUrl.isNotBlank() && productionCalendars.isNotEmpty()) {
googleCalendarService.subscribeToCalendarNotifications(config.applicationUrl, productionCalendars) googleCalendarService.subscribeToCalendarNotifications(config.applicationUrl, productionCalendars)
} else { } else {
...@@ -38,6 +40,8 @@ class CalendarSubscriptionScheduler( ...@@ -38,6 +40,8 @@ class CalendarSubscriptionScheduler(
// Subscribe to test calendars // Subscribe to test calendars
val testCalendars = config.getTestCalendars() val testCalendars = config.getTestCalendars()
logger.debug("testCalendars: {}", testCalendars)
logger.debug("testApplicationUrl: {}", config.testApplicationUrl)
if (config.testApplicationUrl.isNotBlank() && testCalendars.isNotEmpty()) { if (config.testApplicationUrl.isNotBlank() && testCalendars.isNotEmpty()) {
googleCalendarService.subscribeToCalendarNotifications(config.testApplicationUrl, testCalendars) googleCalendarService.subscribeToCalendarNotifications(config.testApplicationUrl, testCalendars)
} else { } else {
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
android:label="Effective Office Tablet" android:label="Effective Office Tablet"
android:name=".App" android:name=".App"
android:theme="@android:style/Theme.Material.NoActionBar" android:theme="@android:style/Theme.Material.NoActionBar"
android:lockTaskMode="if_whitelisted" android:lockTaskMode="if_whitelisted">
android:networkSecurityConfig="@xml/network_security_config">
<activity <activity
android:name=".AppActivity" android:name=".AppActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
......
...@@ -12,7 +12,7 @@ class ServerMessagingService() : ...@@ -12,7 +12,7 @@ class ServerMessagingService() :
private val collector: Collector<String> by inject() private val collector: Collector<String> by inject()
override fun onMessageReceived(message: RemoteMessage) { override fun onMessageReceived(message: RemoteMessage) {
Log.i("ReceivedMessage", message.toString()) Log.i("ReceivedMessage", message.data.toString())
collector.emit(message.from?.substringAfter("topics/")?.replace("-test", "") ?: "") collector.emit(message.from?.substringAfter("topics/")?.replace("-test", "") ?: "")
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">109.73.202.144</domain>
</domain-config>
</network-security-config>
\ No newline at end of file
...@@ -3,6 +3,7 @@ package band.effective.office.tablet.root ...@@ -3,6 +3,7 @@ package band.effective.office.tablet.root
import band.effective.office.tablet.core.domain.model.EventInfo import band.effective.office.tablet.core.domain.model.EventInfo
import band.effective.office.tablet.core.domain.model.RoomInfo import band.effective.office.tablet.core.domain.model.RoomInfo
import band.effective.office.tablet.core.domain.model.Slot import band.effective.office.tablet.core.domain.model.Slot
import band.effective.office.tablet.core.domain.useCase.ResourceDisposerUseCase
import band.effective.office.tablet.core.ui.common.ModalWindow import band.effective.office.tablet.core.ui.common.ModalWindow
import band.effective.office.tablet.feature.bookingEditor.presentation.BookingEditorComponent import band.effective.office.tablet.feature.bookingEditor.presentation.BookingEditorComponent
import band.effective.office.tablet.feature.fastBooking.presentation.FastBookingComponent import band.effective.office.tablet.feature.fastBooking.presentation.FastBookingComponent
...@@ -21,14 +22,18 @@ import com.arkivanov.decompose.router.stack.push ...@@ -21,14 +22,18 @@ import com.arkivanov.decompose.router.stack.push
import com.arkivanov.decompose.router.stack.replaceAll import com.arkivanov.decompose.router.stack.replaceAll
import com.arkivanov.decompose.value.Value import com.arkivanov.decompose.value.Value
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
class RootComponent( class RootComponent(
componentContext: ComponentContext, componentContext: ComponentContext,
) : ComponentContext by componentContext { ) : ComponentContext by componentContext, KoinComponent {
private val navigation = StackNavigation<Config>() private val navigation = StackNavigation<Config>()
private val modalNavigation = SlotNavigation<ModalWindowsConfig>() private val modalNavigation = SlotNavigation<ModalWindowsConfig>()
private val resourceDisposerUseCase: ResourceDisposerUseCase by inject()
val modalWindowSlot = childSlot( val modalWindowSlot = childSlot(
source = modalNavigation, source = modalNavigation,
childFactory = ::createModalWindow, childFactory = ::createModalWindow,
...@@ -43,6 +48,10 @@ class RootComponent( ...@@ -43,6 +48,10 @@ class RootComponent(
childFactory = ::createChild, childFactory = ::createChild,
) )
init {
resourceDisposerUseCase()
}
private fun createChild( private fun createChild(
config: Config, config: Config,
componentContext: ComponentContext componentContext: ComponentContext
......
...@@ -21,9 +21,9 @@ class ResourceDisposerUseCase( ...@@ -21,9 +21,9 @@ class ResourceDisposerUseCase(
private val refreshDataUseCase: RefreshDataUseCase, private val refreshDataUseCase: RefreshDataUseCase,
) { ) {
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
private val updateJob: Job private var updateJob: Job? = null
init { operator fun invoke() {
updateJob = scope.launch { updateJob = scope.launch {
networkRoomRepository.subscribeOnUpdates().collect { networkRoomRepository.subscribeOnUpdates().collect {
refreshDataUseCase() refreshDataUseCase()
...@@ -36,7 +36,7 @@ class ResourceDisposerUseCase( ...@@ -36,7 +36,7 @@ class ResourceDisposerUseCase(
* Should be called when the use case is no longer needed to prevent memory leaks. * Should be called when the use case is no longer needed to prevent memory leaks.
*/ */
fun dispose() { fun dispose() {
updateJob.cancel() updateJob?.cancel()
scope.cancel() scope.cancel()
} }
} }
\ No newline at end of file
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать