This is an invite Bot for Matrix. Depending on the Keycloak groups of a given user, it will create and/or invite users to specific Matrix rooms and/or spaces.
It uses three APIs for this purpose (the Matrix Client-Server API, the Synapse Admin API and the Keycloak Admin API).
This bot consists of two separate and independent parts:
Sequence diagram of the DM logic:
flowchart TD
    A[User joins monitored room] -->B[User known to Keycloak?]
    B -->|Yes| C[Check Groups]
    B -->|No| D[Do nothing]
    C -->|Crew| E[Space exists?]
    C -->|Owner| F[Space exists?]
    E -->|Yes| G[Send 'Exists DM' & Invite]
    E -->|No| H[Do nothing]
    F -->|Yes| G
    F -->|No| J[Send 'Create DM']
    To test/develop this project locally, you need to have Node.js installed (for correct version, see .nvmrc). Just clone the repo, switch to the new folder and run npm install. Now add/adjust your .env file and then run npm run dev.
- Clone the project
 - Either create a 
.envfile or set the environment variables inside ofdocker-compose.yml - Run 
docker-compose up 
- Somehow the Keycloak API always fails on first start. Restarting the bot fixes it, but it's annoying and should be fixed.
 - Currently, message encryption is not supported, b/c there seems to be no way to extract a proper token from Synapse when using SSO login. The token that can be extracted from Element is device-specific does not work with encryption enabled.