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

Improve the way that registrations open state is handled in pleroma

parent 78ea501f
No related branches found
No related tags found
No related merge requests found
......@@ -242,9 +242,16 @@ function pleroma_setting_emoji {
function pleroma_setting_registration {
allow_registration="$1"
if [[ "$allow_registration" == '1' ]]; then
if ! grep -q 'registrations_open' $pleroma_secret; then
sed -i '/config :pleroma, :instance/a registrations_open: true,' $pleroma_secret
sed -i 's|registrations_open:| registrations_open:|g' $pleroma_secret
fi
sed -i 's|registrations_open: false|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: False|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: false|registrations_open: true|g' $pleroma_secret
sed -i 's|registrations_open: False|registrations_open: true|g' $pleroma_secret
sed -i 's|"registrationOpen": false|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": False|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
cd $PLEROMA_DIR || exit 56
......@@ -252,8 +259,14 @@ function pleroma_setting_registration {
fi
if [[ "$allow_registration" == '0' ]]; then
if ! grep -q 'registrations_open' $pleroma_secret; then
sed -i '/config :pleroma, :instance/a registrations_open: false,' $pleroma_secret
sed -i 's|registrations_open:| registrations_open:|g' $pleroma_secret
fi
sed -i 's|registrations_open: true|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: True|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: true|registrations_open: false|g' $pleroma_secret
sed -i 's|registrations_open: True|registrations_open: false|g' $pleroma_secret
sed -i 's|"registrationOpen": true|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": True|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
cd $PLEROMA_DIR || exit 45
......@@ -1164,6 +1177,23 @@ function upgrade_pleroma {
expire_pleroma_posts "$PLEROMA_DOMAIN_NAME" "$PLEROMA_EXPIRE_MONTHS"
create_pleroma_blocklist
# if the registrations state doesn't exist in the secret config then add it
if ! grep -q 'registrations_open' $pleroma_secret; then
if grep -q '"registrationOpen": false' $PLEROMA_DIR/priv/static/static/config.json; then
pleroma_setting_registration 0
else
pleroma_setting_registration 1
fi
fi
# if there is disagreement in the registrations state then
# default to the value used in config.json
if grep -q '"registrationOpen": false' $PLEROMA_DIR/priv/static/static/config.json; then
if grep -q 'registrations_open: true' $PLEROMA_DIR/config/config.exs; then
pleroma_setting_registration 0
fi
fi
#pleroma_enable_tor
CURR_PLEROMA_COMMIT=$(get_completion_param "pleroma commit")
......@@ -1321,6 +1351,16 @@ function upgrade_pleroma {
write_config_param PLEROMA_PUSH_PRIVATE_KEY "$PLEROMA_PUSH_PRIVATE_KEY"
fi
# if there is a difference between registrations state then default to the one in the secret config
if grep -q 'registrations_open: false' "$pleroma_secret"; then
if grep -q 'registrations_open: true' $PLEROMA_DIR/config/config.exs; then
sed -i 's|registrations_open: true|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
fi
if grep -q 'registrations_open: True' $PLEROMA_DIR/config/config.exs; then
sed -i 's|registrations_open: True|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
fi
fi
pleroma_recompile
# migrate database
......
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