diff --git a/src/main/kotlin/net/leanix/githubagent/services/GitHubScanningService.kt b/src/main/kotlin/net/leanix/githubagent/services/GitHubScanningService.kt index be72f0f..0b269dc 100644 --- a/src/main/kotlin/net/leanix/githubagent/services/GitHubScanningService.kt +++ b/src/main/kotlin/net/leanix/githubagent/services/GitHubScanningService.kt @@ -10,12 +10,13 @@ import org.springframework.stereotype.Service class GitHubScanningService( private val gitHubClient: GitHubClient, private val cachingService: CachingService, + private val webSocketService: WebSocketService ) { fun scanGitHubResources() { val jwtToken = cachingService.get("jwtToken") ?: throw JwtTokenNotFound() val installations = getInstallations(jwtToken.toString()) - generateOrganizations(installations) - // send organizations to backend + val organizations = generateOrganizations(installations) + webSocketService.sendMessage("/app/ghe/organizations", organizations) } private fun getInstallations(jwtToken: String): List { diff --git a/src/main/kotlin/net/leanix/githubagent/services/WebSocketService.kt b/src/main/kotlin/net/leanix/githubagent/services/WebSocketService.kt index 7f9e551..8959113 100644 --- a/src/main/kotlin/net/leanix/githubagent/services/WebSocketService.kt +++ b/src/main/kotlin/net/leanix/githubagent/services/WebSocketService.kt @@ -17,4 +17,8 @@ class WebSocketService( logger.info("init session") stompSession = webSocketClientConfig.initSession() } + + fun sendMessage(topic: String, data: Any) { + stompSession!!.send(topic, data) + } }