diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..2982fb6 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,37 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("org.springframework.boot") version "2.6.2" + id("io.spring.dependency-management") version "1.0.11.RELEASE" + kotlin("jvm") version "1.6.10" + kotlin("plugin.spring") version "1.6.10" +} + +group = "eu.fosil" +version = "0.0.1-SNAPSHOT" +java.sourceCompatibility = JavaVersion.VERSION_17 + +repositories { + mavenCentral() +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter") + implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation ("net.folivo:matrix-spring-boot-bot:0.5.2") + runtimeOnly("com.h2database:h2") + runtimeOnly("io.r2dbc:r2dbc-h2") + testImplementation("org.springframework.boot:spring-boot-starter-test") +} + +tasks.withType { + kotlinOptions { + freeCompilerArgs = listOf("-Xjsr305=strict") + jvmTarget = "17" + } +} + +tasks.withType { + useJUnitPlatform() +} diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..064255a --- /dev/null +++ b/docker/README.md @@ -0,0 +1,32 @@ +# Okupa mi coche - Docker containers for the backend +Guide for seting up a local development environment for the backend. + +## Setup +1. Install Docker in local machine +2. Add following line to /etc/hosts +``` +127.0.0.1 okupamicoche-synapse +``` + +5. Generate data folder for Synapse +``` +cd docker/synape +docker run -it --rm \ + --mount type=volume,src=synapse-data,dst=/data \ + -e SYNAPSE_SERVER_NAME=okupamicoche-synapse \ + -e SYNAPSE_REPORT_STATS=no \ + okupamicoche-synapse generate +``` +6. Run dockerized Synapse +``` +docker run --name okupamicoche-synapse -p 8008:8008 --mount type=volume,src=synapse-data,dst=/data \ +-e SYNAPSE_CONFIG_PATH=/homeserver.yaml \ +-v $(pwd)/homeserver.yaml:/homeserver.yaml -v $(pwd)/okupamicoche-appservice.yaml:/okupamicoche-appservice.yaml \ +okupamicoche-synapse +``` + +## Run +`docker start okupamicoche-synapse` + +## Inspect containter +`docker exec -t -i okupamicoche-synapse /bin/bash` diff --git a/docker/synapse/homeserver.yaml b/docker/synapse/homeserver.yaml new file mode 100644 index 0000000..9953790 --- /dev/null +++ b/docker/synapse/homeserver.yaml @@ -0,0 +1,29 @@ +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 ] + compress: false +database: + name: sqlite3 + args: + database: /data/homeserver.db +log_config: "/data/okupamicoche-synapse.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 +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" +sso: + client_whitelist: + - http://localhost:4200/ +app_service_config_files: + - /okupamicoche-appservice.yaml diff --git a/docker/synapse/okupamicoche-appservice.yaml b/docker/synapse/okupamicoche-appservice.yaml new file mode 100644 index 0000000..49778fc --- /dev/null +++ b/docker/synapse/okupamicoche-appservice.yaml @@ -0,0 +1,11 @@ +id: "Okupa mi coche" +url: "http://172.17.0.1:8080" +as_token: "30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46" +hs_token: "312df522183efd404ec1cd22d2ffa4bbc76a8c1ccf541dd692eef281356bb74e" +sender_localpart: "okupamicoche" +namespaces: + users: [ ] + aliases: + - regex: "#viaje_.*" + exclusive: true + rooms: [ ] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d2880ba --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/matrix.mv.db b/matrix.mv.db new file mode 100644 index 0000000..60d63f6 Binary files /dev/null and b/matrix.mv.db differ diff --git a/matrix.trace.db b/matrix.trace.db new file mode 100644 index 0000000..37523d9 --- /dev/null +++ b/matrix.trace.db @@ -0,0 +1,211 @@ +2022-01-11 00:25:43 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Function "VERSION" not found; SQL statement: +select version() [90022-200] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) + at org.h2.message.DbException.get(DbException.java:205) + at org.h2.message.DbException.get(DbException.java:181) + at org.h2.command.Parser.readJavaFunction(Parser.java:3565) + at org.h2.command.Parser.readFunction(Parser.java:3770) + at org.h2.command.Parser.readTerm(Parser.java:4305) + at org.h2.command.Parser.readFactor(Parser.java:3343) + at org.h2.command.Parser.readSum(Parser.java:3330) + at org.h2.command.Parser.readConcat(Parser.java:3305) + at org.h2.command.Parser.readCondition(Parser.java:3108) + at org.h2.command.Parser.readExpression(Parser.java:3059) + at org.h2.command.Parser.parseSelectExpressions(Parser.java:2931) + at org.h2.command.Parser.parseSelect(Parser.java:2952) + at org.h2.command.Parser.parseQuerySub(Parser.java:2817) + at org.h2.command.Parser.parseSelectUnion(Parser.java:2649) + at org.h2.command.Parser.parseQuery(Parser.java:2620) + at org.h2.command.Parser.parsePrepared(Parser.java:868) + at org.h2.command.Parser.parse(Parser.java:843) + at org.h2.command.Parser.parse(Parser.java:815) + at org.h2.command.Parser.prepareCommand(Parser.java:738) + at org.h2.engine.Session.prepareLocal(Session.java:657) + at org.h2.engine.Session.prepareCommand(Session.java:595) + at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) + at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78) + at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:110) + at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java) + at liquibase.database.core.CockroachDatabase.isCorrectDatabaseImplementation(CockroachDatabase.java:38) + at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:101) + at liquibase.integration.spring.SpringLiquibase.createDatabase(SpringLiquibase.java:355) + at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:322) + at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:267) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) + at eu.fosil.okupamicoche.OkupaMiCocheAppServiceApplicationKt.main(OkupaMiCocheAppServiceApplication.kt:13) +2022-01-11 00:25:44 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DATABASECHANGELOGLOCK" not found; SQL statement: +SELECT COUNT(*) FROM PUBLIC.DATABASECHANGELOGLOCK [42102-200] +2022-01-11 00:31:11 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Function "VERSION" not found; SQL statement: +select version() [90022-200] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) + at org.h2.message.DbException.get(DbException.java:205) + at org.h2.message.DbException.get(DbException.java:181) + at org.h2.command.Parser.readJavaFunction(Parser.java:3565) + at org.h2.command.Parser.readFunction(Parser.java:3770) + at org.h2.command.Parser.readTerm(Parser.java:4305) + at org.h2.command.Parser.readFactor(Parser.java:3343) + at org.h2.command.Parser.readSum(Parser.java:3330) + at org.h2.command.Parser.readConcat(Parser.java:3305) + at org.h2.command.Parser.readCondition(Parser.java:3108) + at org.h2.command.Parser.readExpression(Parser.java:3059) + at org.h2.command.Parser.parseSelectExpressions(Parser.java:2931) + at org.h2.command.Parser.parseSelect(Parser.java:2952) + at org.h2.command.Parser.parseQuerySub(Parser.java:2817) + at org.h2.command.Parser.parseSelectUnion(Parser.java:2649) + at org.h2.command.Parser.parseQuery(Parser.java:2620) + at org.h2.command.Parser.parsePrepared(Parser.java:868) + at org.h2.command.Parser.parse(Parser.java:843) + at org.h2.command.Parser.parse(Parser.java:815) + at org.h2.command.Parser.prepareCommand(Parser.java:738) + at org.h2.engine.Session.prepareLocal(Session.java:657) + at org.h2.engine.Session.prepareCommand(Session.java:595) + at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) + at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78) + at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:110) + at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java) + at liquibase.database.core.CockroachDatabase.isCorrectDatabaseImplementation(CockroachDatabase.java:38) + at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:101) + at liquibase.integration.spring.SpringLiquibase.createDatabase(SpringLiquibase.java:355) + at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:322) + at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:267) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) + at eu.fosil.okupamicoche.OkupaMiCocheAppServiceApplicationKt.main(OkupaMiCocheAppServiceApplication.kt:13) +2022-01-11 00:43:11 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Function "VERSION" not found; SQL statement: +select version() [90022-200] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) + at org.h2.message.DbException.get(DbException.java:205) + at org.h2.message.DbException.get(DbException.java:181) + at org.h2.command.Parser.readJavaFunction(Parser.java:3565) + at org.h2.command.Parser.readFunction(Parser.java:3770) + at org.h2.command.Parser.readTerm(Parser.java:4305) + at org.h2.command.Parser.readFactor(Parser.java:3343) + at org.h2.command.Parser.readSum(Parser.java:3330) + at org.h2.command.Parser.readConcat(Parser.java:3305) + at org.h2.command.Parser.readCondition(Parser.java:3108) + at org.h2.command.Parser.readExpression(Parser.java:3059) + at org.h2.command.Parser.parseSelectExpressions(Parser.java:2931) + at org.h2.command.Parser.parseSelect(Parser.java:2952) + at org.h2.command.Parser.parseQuerySub(Parser.java:2817) + at org.h2.command.Parser.parseSelectUnion(Parser.java:2649) + at org.h2.command.Parser.parseQuery(Parser.java:2620) + at org.h2.command.Parser.parsePrepared(Parser.java:868) + at org.h2.command.Parser.parse(Parser.java:843) + at org.h2.command.Parser.parse(Parser.java:815) + at org.h2.command.Parser.prepareCommand(Parser.java:738) + at org.h2.engine.Session.prepareLocal(Session.java:657) + at org.h2.engine.Session.prepareCommand(Session.java:595) + at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) + at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78) + at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:110) + at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java) + at liquibase.database.core.CockroachDatabase.isCorrectDatabaseImplementation(CockroachDatabase.java:38) + at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:101) + at liquibase.integration.spring.SpringLiquibase.createDatabase(SpringLiquibase.java:355) + at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:322) + at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:267) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) + at eu.fosil.okupamicoche.OkupaMiCocheAppServiceApplicationKt.main(OkupaMiCocheAppServiceApplication.kt:13) +2022-01-11 00:47:46 jdbc[3]: exception +org.h2.jdbc.JdbcSQLSyntaxErrorException: Function "VERSION" not found; SQL statement: +select version() [90022-200] + at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) + at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) + at org.h2.message.DbException.get(DbException.java:205) + at org.h2.message.DbException.get(DbException.java:181) + at org.h2.command.Parser.readJavaFunction(Parser.java:3565) + at org.h2.command.Parser.readFunction(Parser.java:3770) + at org.h2.command.Parser.readTerm(Parser.java:4305) + at org.h2.command.Parser.readFactor(Parser.java:3343) + at org.h2.command.Parser.readSum(Parser.java:3330) + at org.h2.command.Parser.readConcat(Parser.java:3305) + at org.h2.command.Parser.readCondition(Parser.java:3108) + at org.h2.command.Parser.readExpression(Parser.java:3059) + at org.h2.command.Parser.parseSelectExpressions(Parser.java:2931) + at org.h2.command.Parser.parseSelect(Parser.java:2952) + at org.h2.command.Parser.parseQuerySub(Parser.java:2817) + at org.h2.command.Parser.parseSelectUnion(Parser.java:2649) + at org.h2.command.Parser.parseQuery(Parser.java:2620) + at org.h2.command.Parser.parsePrepared(Parser.java:868) + at org.h2.command.Parser.parse(Parser.java:843) + at org.h2.command.Parser.parse(Parser.java:815) + at org.h2.command.Parser.prepareCommand(Parser.java:738) + at org.h2.engine.Session.prepareLocal(Session.java:657) + at org.h2.engine.Session.prepareCommand(Session.java:595) + at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) + at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:78) + at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:110) + at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java) + at liquibase.database.core.CockroachDatabase.isCorrectDatabaseImplementation(CockroachDatabase.java:38) + at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:101) + at liquibase.integration.spring.SpringLiquibase.createDatabase(SpringLiquibase.java:355) + at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:322) + at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:267) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) + at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) + at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) + at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) + at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) + at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) + at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) + at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) + at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) + at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) + at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) + at eu.fosil.okupamicoche.OkupaMiCocheAppServiceApplicationKt.main(OkupaMiCocheAppServiceApplication.kt:13) diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..f7c4106 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "okupamicoche" diff --git a/src/main/kotlin/eu/fosil/OkupaMiCocheAppServiceApplication.kt b/src/main/kotlin/eu/fosil/OkupaMiCocheAppServiceApplication.kt new file mode 100644 index 0000000..4af561d --- /dev/null +++ b/src/main/kotlin/eu/fosil/OkupaMiCocheAppServiceApplication.kt @@ -0,0 +1,11 @@ +package eu.fosil.okupamicoche + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class OkupaMiCocheAppServiceApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/src/main/resources/.application.yml.kate-swp b/src/main/resources/.application.yml.kate-swp new file mode 100644 index 0000000..933d0bb Binary files /dev/null and b/src/main/resources/.application.yml.kate-swp differ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..89beaa0 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,69 @@ +server: + port: 8081 + +spring: + datasource: + driver-class-name: org.h2.Driver + url: jdbc:h2:file:./okupamicoche;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE + jpa: + database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: update + jackson: + serialization: + write-dates-as-timestamps: false + +logging: + level: + org: + springframework: INFO + eu.fosil.okupamicoche: DEBUG + +matrix: + bot: + # The domain-part of matrix-ids.E.g. example.org when your userIds look like @unicorn:example.org + serverName: okupamicoche-synapse + # The localpart (username) of the user associated with the application service + # or just the username of your bot. + username: okupamicoche + # (optional) Display name for the bot user. + displayname: Okupa mi coche + # (optional) The mode you want to use to create a bot. Default is CLIENT. The other is APPSERVICE. + mode: APPSERVICE + # (optional) Configure how users managed by your bot do automatically join rooms. + # ENABLED allows automatic joins to every invited room. + # DISABLED disables this feature. + # Default is RESTRICTED, which means, that only automatic joins to serverName are allowed. + autoJoin: DISABLED + # (optional) Configure if ALL membership changes should be tracked/saved with help of MatrixAppserviceRoomService + # or only membership changes of users, which are MANAGED by the bridge. Default is ALL (no tracking/saving). + trackMembership: ALL + # Connection setting to the database for migration purpose only (only jdbc drivers ar supported) + migration: + url: jdbc:h2:file:./matrix + username: sa + password: + # Connection settings to the database (only r2dbc drivers are supported) + database: + url: r2dbc:h2:file:///./matrix + username: sa + password: + client: + homeServer: + # The hostname of your Homeserver. + hostname: okupamicoche-synapse + # (optional) The port of your Homeserver. Default is 443. + port: 8008 + # (optional) Use http or https. Default is true (so uses https). + secure: false + # The token to authenticate against the Homeserver. + token: "30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46" + appservice: + # A unique token for Homeservers to use to authenticate requests to application services. + hsToken: "312df522183efd404ec1cd22d2ffa4bbc76a8c1ccf541dd692eef281356bb74e" + # A list of users, aliases and rooms namespaces that the application service controls. + namespaces: + users: [ ] + aliases: + - localpartRegex: "viaje_.*" + rooms: [ ] diff --git a/src/test/kotlin/eu/fosil/OkupaMiCocheAppServiceApplicationTests.kt b/src/test/kotlin/eu/fosil/OkupaMiCocheAppServiceApplicationTests.kt new file mode 100644 index 0000000..92043bf --- /dev/null +++ b/src/test/kotlin/eu/fosil/OkupaMiCocheAppServiceApplicationTests.kt @@ -0,0 +1,13 @@ +package eu.fosil.okupamicoche + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class OkupaMiCocheAppServiceApplicationTests { + + @Test + fun contextLoads() { + } + +}