This commit is contained in:
Dominic Grimm 2024-02-18 20:34:36 +01:00
parent 33282a4db9
commit 588998bce7
5 changed files with 7 additions and 1 deletions

View file

@ -31,7 +31,6 @@ import akka.util.ByteString
import akka.stream.scaladsl.Source
import scala.util.Success
import scala.util.Failure
import concurrent.ExecutionContext.Implicits.global
class MqttEventListenerProvider(
val session: KeycloakSession,
@ -65,6 +64,7 @@ class MqttEventListenerProvider(
override def close(): Unit = {}
private def sendMessage(payload: Payload): Unit =
import concurrent.ExecutionContext.Implicits.global
import MqttEventListenerProviderFactory.system
val topic = s"${mqttOptions.topic}/${payload.topic}"
@ -81,3 +81,4 @@ class MqttEventListenerProvider(
s"Failed to publish message: ${exception.getMessage()}"
)
}
end MqttEventListenerProvider

View file

@ -37,6 +37,7 @@ object MqttEventListenerProviderFactory:
private val PUBLISHER_ID = "keycloak"
implicit val system: ActorSystem = ActorSystem()
end MqttEventListenerProviderFactory
class MqttEventListenerProviderFactory(
var data: MqttEventListenerProviderFactoryData
@ -118,3 +119,4 @@ class MqttEventListenerProviderFactory(
override def close(): Unit = {}
override def getId(): String = MqttEventListenerProviderFactory.PLUGIN_ID
end MqttEventListenerProviderFactory

View file

@ -38,6 +38,7 @@ object MqttOptions:
retained,
qos
)
end MqttOptions
private final case class MqttOptions(
topic: String,

View file

@ -60,6 +60,7 @@ object Payload:
error,
resourceTypeAsString = event.getResourceTypeAsString()
)
end Payload
private final case class Payload(
admin: Boolean,

View file

@ -38,6 +38,7 @@ object PayloadAuthDetails:
userId = auth.getClientId(),
ipAddress = auth.getIpAddress()
)
end PayloadAuthDetails
private final case class PayloadAuthDetails(
realmId: String,