Skip to content
Snippets Groups Projects
Commit 981d97f2 authored by Bob Mottram's avatar Bob Mottram
Browse files

Handle onion domains when removing matrix users

parent 9ba2aea1
No related branches found
No related tags found
No related merge requests found
......@@ -410,6 +410,11 @@ function create_matrix_user_removal_script {
homebase="http://$(cat /var/lib/tor/hidden_service_matrix/hostname)"
fi
matrix_domain=$MATRIX_DOMAIN_NAME
if [[ "$ONION_ONLY" != 'no' ]]; then
matrix_domain=$(cat /var/lib/tor/hidden_service_matrix/hostname)
fi
matrix_remove_user=/usr/bin/matrix-remove-user
{ echo '#!/bin/bash';
echo "cd $MATRIX_DATA_DIR || exit 1";
......@@ -422,11 +427,45 @@ function create_matrix_user_removal_script {
echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select token from access_tokens where user_id like '\$ADMIN' order by id desc limit 1;\")";
echo "TOKEN=\$(echo \$BUFFER|awk '{print \$2}')";
echo 'set -x';
echo "${curl_command} -X POST \"${homebase}/_matrix/client/r0/admin/deactivate/%40\$remove_username%3A$MATRIX_DOMAIN_NAME?access_token=\$TOKEN\" --data '{\"erase\": true}'"; } > $matrix_remove_user
echo "${curl_command} -X POST \"${homebase}/_matrix/client/r0/admin/deactivate/%40\$remove_username%3A$matrix_domain?access_token=\$TOKEN\" --data '{\"erase\": true}'"; } > $matrix_remove_user
chmod +x $matrix_remove_user
}
function create_matrix_whois_script {
read_config_param ONION_ONLY
read_config_param MY_USERNAME
read_config_param MATRIX_DOMAIN_NAME
curl_command='curl'
homebase="https://$MATRIX_DOMAIN_NAME"
if [[ "$ONION_ONLY" != 'no' ]]; then
curl_command='torsocks curl'
homebase="http://$(cat /var/lib/tor/hidden_service_matrix/hostname)"
fi
matrix_domain=$MATRIX_DOMAIN_NAME
if [[ "$ONION_ONLY" != 'no' ]]; then
matrix_domain=$(cat /var/lib/tor/hidden_service_matrix/hostname)
fi
matrix_whois_filename=/usr/bin/matrix-whois
{ echo '#!/bin/bash';
echo "cd $MATRIX_DATA_DIR || exit 1";
echo "username=\$1";
echo "if [ ! \"\$username\" ]; then";
echo ' exit 1';
echo 'fi';
echo "ADMIN=\"@${MY_USERNAME}:$MATRIX_DOMAIN_NAME\"";
echo 'BUSY="pragma busy_timeout=20000"';
echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select token from access_tokens where user_id like '\$ADMIN' order by id desc limit 1;\")";
echo "TOKEN=\$(echo \$BUFFER|awk '{print \$2}')";
echo 'set -x';
echo "${curl_command} -X POST \"${homebase}/_matrix/client/r0/admin/whois/%40\$username%3A$matrix_domain?access_token=\$TOKEN\" --data '{}'"; } > $matrix_whois_filename
chmod +x $matrix_whois_filename
}
function remove_user_matrix {
remove_username="$1"
......@@ -1159,5 +1198,9 @@ function install_matrix {
increment_app_install_progress
create_matrix_whois_script
increment_app_install_progress
APP_INSTALLED=1
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment