From 24b0d72d96451f89b8359055284b4f7b39a3cbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 11 Jun 2024 16:04:36 +0200 Subject: [PATCH] matrix-synapse: fix user check --- checks/matrix-synapse/default.nix | 2 ++ clanModules/matrix-synapse/default.nix | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/checks/matrix-synapse/default.nix b/checks/matrix-synapse/default.nix index 10395d26..972f3d1e 100644 --- a/checks/matrix-synapse/default.nix +++ b/checks/matrix-synapse/default.nix @@ -73,6 +73,8 @@ machine.wait_for_unit("matrix-synapse") machine.succeed("${pkgs.netcat}/bin/nc -z -v ::1 8008") machine.succeed("${pkgs.curl}/bin/curl -Ssf -L http://localhost/_matrix/static/ -H 'Host: matrix.clan.test'") + machine.succeed("${pkgs.curl}/bin/curl -Svf -L -H 'Authorization: Bearer supersecret' http://localhost:8008/_synapse/admin/v1/whois/@admin:clan.test >&2") + machine.succeed("${pkgs.curl}/bin/curl -Svf -L -H 'Authorization: Bearer supersecret' http://localhost:8008/_synapse/admin/v1/whois/@someuser:clan.test >&2") ''; } ) diff --git a/clanModules/matrix-synapse/default.nix b/clanModules/matrix-synapse/default.nix index 3de37c61..a0c35cbb 100644 --- a/clanModules/matrix-synapse/default.nix +++ b/clanModules/matrix-synapse/default.nix @@ -187,7 +187,8 @@ in '' + lib.concatMapStringsSep "\n" (user: '' # only create user if it doesn't exist - if ! curl --header "$headers" "http://localhost:8008/_synapse/admin/v1/whois/${user.name}@${cfg.domain}" >&2; then + set -x + if ! curl --silent --header "@$headers" "http://localhost:8008/_synapse/admin/v1/whois/@${user.name}:${cfg.domain}" >&2; then /run/current-system/sw/bin/matrix-synapse-register_new_matrix_user --password-file ${ config.clanCore.facts.services."matrix-password-${user.name}".secret."matrix-password-${user.name}".path } --user "${user.name}" ${if user.admin then "--admin" else "--no-admin"}