Initial MatrixService and added kotlin-logging

This commit is contained in:
2021-03-26 01:05:47 +01:00
parent a03da9dc74
commit 65d27b0461
4 changed files with 28 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ dependencies {
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("io.github.microutils:kotlin-logging-jvm:2.0.6")
// https://mvnrepository.com/artifact/net.folivo/matrix-spring-boot-bot
implementation (group = "net.folivo", name = "matrix-spring-boot-bot", version = "0.4.5")
developmentOnly("org.springframework.boot:spring-boot-devtools")

View File

@@ -0,0 +1,17 @@
package eu.fosil.okupamicoche.spring.services
import eu.fosil.okupamicoche.usecases.MatrixApi
import mu.KotlinLogging
import net.folivo.matrix.core.model.MatrixId
import net.folivo.matrix.restclient.MatrixClient
import org.springframework.stereotype.Service
@Service
class MatrixService(val matrixClient: MatrixClient): MatrixApi {
private val logger = KotlinLogging.logger {}
override suspend fun createRoom(name: String) {
logger.debug { "Creating room name" }
matrixClient.roomsApi.createRoom(name = name, roomAliasId = MatrixId.RoomAliasId("#$name:synapse"))
}
}

View File

@@ -0,0 +1,5 @@
package eu.fosil.okupamicoche.usecases
interface MatrixApi {
suspend fun createRoom(name: String)
}

View File

@@ -1,5 +1,6 @@
server:
port: 8081
spring:
datasource:
driver-class-name: org.h2.Driver
@@ -14,6 +15,10 @@ spring:
jwt:
issuer-uri: http://localhost:8080/auth/realms/okupamicoche
logging:
level:
eu.fosil.okupamicoche: DEBUG
matrix:
bot:
# The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org