Przeglądaj źródła

pleroma chat can be enabled or disabled from the control panel

Bob Mottram 7 lat temu
rodzic
commit
2b8eddba2f
1 zmienionych plików z 28 dodań i 1 usunięć
  1. 28
    1
      src/freedombone-app-pleroma

+ 28
- 1
src/freedombone-app-pleroma Wyświetl plik

62
                    MY_EMAIL_ADDRESS
62
                    MY_EMAIL_ADDRESS
63
                    MY_USERNAME)
63
                    MY_USERNAME)
64
 
64
 
65
+function pleroma_enable_chat {
66
+    if [[ "$1" == 't'* || "$1" == 'y'* || "$1" == 'T'* || "$1" == 'Y'* ]]; then
67
+        sed -i 's|"chatDisabled":.*|"chatDisabled": false,|g' $PLEROMA_DIR/priv/static/static/config.json
68
+        sed -i 's|:chat, enabled:.*|:chat, enabled: true|g' $PLEROMA_DIR/config/config.exs
69
+    else
70
+        sed -i 's|"chatDisabled":.*|"chatDisabled": true,|g' $PLEROMA_DIR/priv/static/static/config.json
71
+        sed -i 's|:chat, enabled:.*|:chat, enabled: false|g' $PLEROMA_DIR/config/config.exs
72
+    fi
73
+    pleroma_recompile
74
+}
75
+
65
 function create_pleroma_blocklist {
76
 function create_pleroma_blocklist {
66
     { echo '#!/bin/bash';
77
     { echo '#!/bin/bash';
67
       echo "if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then";
78
       echo "if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then";
676
     read_config_param PLEROMA_EXPIRE_MONTHS
687
     read_config_param PLEROMA_EXPIRE_MONTHS
677
     while true
688
     while true
678
     do
689
     do
690
+        chatenabled=
691
+        enablechatstr=$'Enable chat system'
692
+        if grep -q ':chat, enabled: false' $PLEROMA_DIR/config/config.exs; then
693
+            chatenabled=1
694
+            enablechatstr=$'Disable chat system'
695
+        fi
696
+
679
         W=(1 $"Set a background image"
697
         W=(1 $"Set a background image"
680
            2 $"Set the title"
698
            2 $"Set the title"
681
            3 $"Disable new account registrations"
699
            3 $"Disable new account registrations"
682
            4 $"Add a custom emoji"
700
            4 $"Add a custom emoji"
683
-           5 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)")
701
+           5 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)"
702
+           6 "$enablechatstr")
684
 
703
 
685
         # shellcheck disable=SC2068
704
         # shellcheck disable=SC2068
686
         selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Pleroma" --menu $"Choose an operation, or ESC to exit:" 14 60 5 "${W[@]}" 3>&2 2>&1 1>&3)
705
         selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Pleroma" --menu $"Choose an operation, or ESC to exit:" 14 60 5 "${W[@]}" 3>&2 2>&1 1>&3)
695
             3) pleroma_disable_registrations;;
714
             3) pleroma_disable_registrations;;
696
             4) pleroma_add_emoji;;
715
             4) pleroma_add_emoji;;
697
             5) pleroma_set_expire_months;;
716
             5) pleroma_set_expire_months;;
717
+            6) if [ $chatenabled ]; then
718
+                   pleroma_enable_chat false
719
+               else
720
+                   pleroma_enable_chat true
721
+               fi
722
+               ;;
698
         esac
723
         esac
699
     done
724
     done
700
 }
725
 }
1224
     sed -i '/config :pleroma, :media_proxy/!b;n;c####enabled: true,' $PLEROMA_DIR/config/config.exs
1249
     sed -i '/config :pleroma, :media_proxy/!b;n;c####enabled: true,' $PLEROMA_DIR/config/config.exs
1225
     sed -i 's|####enabled|  enabled|g' $PLEROMA_DIR/config/config.exs
1250
     sed -i 's|####enabled|  enabled|g' $PLEROMA_DIR/config/config.exs
1226
     sed -i 's|redirect_on_failure:.*|redirect_on_failure: false|g' $PLEROMA_DIR/config/config.exs
1251
     sed -i 's|redirect_on_failure:.*|redirect_on_failure: false|g' $PLEROMA_DIR/config/config.exs
1252
+    sed -i 's|:chat, enabled:.*|:chat, enabled: false|g' $PLEROMA_DIR/config/config.exs
1227
 
1253
 
1228
     # set registrations open initially
1254
     # set registrations open initially
1229
     sed -i 's|registrations_open:.*|registrations_open: true,|g' $PLEROMA_DIR/config/config.exs
1255
     sed -i 's|registrations_open:.*|registrations_open: true,|g' $PLEROMA_DIR/config/config.exs
1235
     else
1261
     else
1236
         sed -i 's|"media_proxy".*|"media_proxy": false,|g' $PLEROMA_DIR/priv/static/static/config.json
1262
         sed -i 's|"media_proxy".*|"media_proxy": false,|g' $PLEROMA_DIR/priv/static/static/config.json
1237
     fi
1263
     fi
1264
+    sed -i 's|"chatDisabled":.*|"chatDisabled": true,|g' $PLEROMA_DIR/priv/static/static/config.json
1238
 
1265
 
1239
     systemctl daemon-reload
1266
     systemctl daemon-reload
1240
     systemctl enable pleroma
1267
     systemctl enable pleroma