matrix: add whatsapp bridge

This commit is contained in:
Michele Guerini Rocco 2023-09-03 02:13:13 +02:00
parent bdbfca3642
commit 20455180f9
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -131,7 +131,12 @@ in
event_cache_size = "2K"; event_cache_size = "2K";
max_upload_size = "1000M"; max_upload_size = "1000M";
turn_user_lifetime = "1d"; turn_user_lifetime = "1d";
# bridges configuration
app_service_config_files =
[ "/var/lib/mautrix-whatsapp/whatsapp-registration.yaml" ];
}; };
# Secrets # Secrets
services.matrix-synapse.extraConfigFiles = services.matrix-synapse.extraConfigFiles =
[ [
@ -151,13 +156,19 @@ in
### Database ### Database
services.postgresql.enable = true; services.postgresql.enable = true;
# Create database on the first run # Create databases on the first run
services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" ''
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
TEMPLATE template0 TEMPLATE template0
LC_COLLATE = "C" LC_COLLATE = "C"
LC_CTYPE = "C"; LC_CTYPE = "C";
CREATE ROLE "mautrix-whatsapp" WITH LOGIN PASSWORD 'whatsapp';
CREATE DATABASE "mautrix-whatsapp" WITH OWNER "mautrix-whatsapp"
TEMPLATE template0
LC_COLLATE = "C"
LC_CTYPE = "C";
''; '';
@ -201,4 +212,36 @@ in
''; '';
}; };
### Whatsapp bridge
# allow synapse to read the shared secrets
users.users.matrix-synapse.extraGroups = [ "mautrix-whatsapp" ];
services.mautrix-whatsapp =
{
enable = true;
serviceDependencies = [ "postgresql.service" ];
settings.appservice =
{ database.type = "postgres";
database.uri = "postgresql:///mautrix-whatsapp?host=/run/postgresql";
};
settings.bridge =
{ encryption =
{ allow = true;
default = true;
require = true;
};
permissions =
{ "maxwell.ydns.eu" = "user";
"@rnhmjoj:maxwell.ydns.eu" = "admin";
};
relay.enabled = false;
mute_bridging = true;
};
settings.whatsapp =
{ os_name = "Chrome (Linux)";
browser_name = "chrome";
};
};
} }