diff --git a/.gitignore b/.gitignore index 0c9d4ef..9aafcc9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ build/ matrix.mv.db matrix.trace.db +# Synapse data +docker/synapse/data + ### STS ### .apt_generated .classpath diff --git a/docker/synapse/homeserver.yaml b/docker/synapse/config/homeserver.yaml old mode 100644 new mode 100755 similarity index 58% rename from docker/synapse/homeserver.yaml rename to docker/synapse/config/homeserver.yaml index f06101f..0f3df5b --- a/docker/synapse/homeserver.yaml +++ b/docker/synapse/config/homeserver.yaml @@ -1,27 +1,26 @@ server_name: "okupamicoche-synapse" pid_file: /data/homeserver.pid -public_baseurl: http://okupamicoche-synapse:8008/ listeners: - port: 8008 tls: false type: http x_forwarded: true + resources: - - names: [ client, federation ] + - names: [client, federation] compress: false database: name: sqlite3 args: database: /data/homeserver.db -enable_registration: true -log_config: "/data/okupamicoche-synapse.log.config" +log_config: "/config/localhost.log.config" media_store_path: "/data/media_store" -registration_shared_secret: "Y_XNuno*Dh,T2IpHA;i,bWF^fg&x.*t=iEz*@:y5REBMhgCA63" -report_stats: false +signing_key_path: "/config/localhost.signing.key" macaroon_secret_key: "6VvBQj_TedGcDDB_z,-qXV1W3:.CXrRG6AWF&4p:~iGNguy&_h" -form_secret: "FM,2TSq++sZ@Tl0atcQP" -signing_key_path: "/data/okupamicoche-synapse.signing.key" trusted_key_servers: - server_name: "matrix.org" +report_stats: false +suppress_key_server_warning: true +enable_registration: true app_service_config_files: - - /okupamicoche-appservice.yaml + - /config/okupamicoche-appservice.yaml diff --git a/docker/synapse/config/localhost.log.config b/docker/synapse/config/localhost.log.config new file mode 100755 index 0000000..f78346a --- /dev/null +++ b/docker/synapse/config/localhost.log.config @@ -0,0 +1,33 @@ + +version: 1 + +formatters: + precise: + format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + +filters: + context: + (): synapse.util.logcontext.LoggingContextFilter + request: "" + +handlers: + console: + class: logging.StreamHandler + formatter: precise + filters: [context] + +loggers: + synapse: + level: WARNING + + synapse.storage.SQL: + # beware: increasing this to DEBUG will make synapse log sensitive + # information such as access tokens. + level: WARNING + + rest_auth_provider: + level: INFO + +root: + level: WARNING + handlers: [console] diff --git a/docker/synapse/config/localhost.signing.key b/docker/synapse/config/localhost.signing.key new file mode 100755 index 0000000..3bd1b72 --- /dev/null +++ b/docker/synapse/config/localhost.signing.key @@ -0,0 +1 @@ +ed25519 a_EgjW U0b5hmg9zXoLxAZFVDLTvtggKw+vkZQepCgjL8ZYRfI \ No newline at end of file diff --git a/docker/synapse/okupamicoche-appservice.yaml b/docker/synapse/config/okupamicoche-appservice.yaml similarity index 100% rename from docker/synapse/okupamicoche-appservice.yaml rename to docker/synapse/config/okupamicoche-appservice.yaml diff --git a/docker/synapse/docker-compose.yml b/docker/synapse/docker-compose.yml new file mode 100644 index 0000000..43a1b43 --- /dev/null +++ b/docker/synapse/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3.3" + +services: + synapse: + image: "matrixdotorg/synapse:latest" + container_name: "okupamicoche-synapse" + volumes: + - "./data:/data" + - "./config:/config" + environment: + VIRTUAL_HOST: "localhost" + VIRTUAL_PORT: 8008 + SYNAPSE_SERVER_NAME: "okupamicoche-synapse" + SYNAPSE_REPORT_STATS: "no" + SYNAPSE_CONFIG_DIR: "/config" + GUI: 1000 + UID: 1000 + ports: + - "8008:8008" diff --git a/src/main/kotlin/eu/fosil/Application.kt b/src/main/kotlin/eu/fosil/Application.kt index 1e79529..172840f 100644 --- a/src/main/kotlin/eu/fosil/Application.kt +++ b/src/main/kotlin/eu/fosil/Application.kt @@ -4,7 +4,6 @@ import io.ktor.http.* import io.ktor.server.engine.* import io.ktor.server.netty.* import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import net.folivo.trixnity.appservice.rest.DefaultAppserviceService import net.folivo.trixnity.appservice.rest.MatrixAppserviceProperties @@ -18,33 +17,25 @@ import net.folivo.trixnity.client.api.MatrixApiClient import net.folivo.trixnity.core.model.RoomAliasId import net.folivo.trixnity.core.model.RoomId import net.folivo.trixnity.core.model.UserId -import net.folivo.trixnity.core.model.events.m.room.RoomMessageEventContent val matrixClient = MatrixApiClient( baseUrl = Url("http://okupamicoche-synapse:8008/"), -).apply { accessToken.value = "syt_dGVzdDM_OIheLExYmDBsfAeENWfF_3BwxFM" } -//).apply { accessToken.value = "30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46" } // TODO Error 500 +).apply { accessToken.value = "30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46" } suspend fun main() { coroutineScope { - matrixClient.sync.subscribe { println(it.content.body) } - - matrixClient.sync.subscribeAllEvents { // this is a shortcut for .subscribe { } -// println(it) - } - - launch { - matrixClient.sync.start(wait = true, scope = this) // you need to start the sync to receive messages - } - val appserviceService = DefaultAppserviceService( EventTnxService(), UserService(), RoomService() ) - println(3) + + appserviceService.subscribeAllEvents { + event -> println(event) + } + launch { embeddedServer(Netty, port = 8080, host = "0.0.0.0") { matrixAppserviceModule( @@ -53,7 +44,6 @@ suspend fun main() { ) }.start(wait = true) } - println(4) } diff --git a/src/test/kotlin/eu/fosil/ApplicationTest.kt b/src/test/kotlin/eu/fosil/ApplicationTest.kt index d5c0552..76ea9e1 100644 --- a/src/test/kotlin/eu/fosil/ApplicationTest.kt +++ b/src/test/kotlin/eu/fosil/ApplicationTest.kt @@ -1,13 +1,4 @@ package eu.fosil -import io.ktor.server.routing.* -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.response.* -import io.ktor.server.request.* -import kotlin.test.* -import io.ktor.server.testing.* -import eu.fosil.plugins.* - class ApplicationTest { } \ No newline at end of file