소스 검색

pleroma chat can be enabled or disabled from the control panel

Bob Mottram 7 년 전
부모
커밋
2b8eddba2f
1개의 변경된 파일28개의 추가작업 그리고 1개의 파일을 삭제
  1. 28
    1
      src/freedombone-app-pleroma

+ 28
- 1
src/freedombone-app-pleroma 파일 보기

@@ -62,6 +62,17 @@ pleroma_variables=(ONION_ONLY
62 62
                    MY_EMAIL_ADDRESS
63 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 76
 function create_pleroma_blocklist {
66 77
     { echo '#!/bin/bash';
67 78
       echo "if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then";
@@ -676,11 +687,19 @@ function configure_interactive_pleroma {
676 687
     read_config_param PLEROMA_EXPIRE_MONTHS
677 688
     while true
678 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 697
         W=(1 $"Set a background image"
680 698
            2 $"Set the title"
681 699
            3 $"Disable new account registrations"
682 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 704
         # shellcheck disable=SC2068
686 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,6 +714,12 @@ function configure_interactive_pleroma {
695 714
             3) pleroma_disable_registrations;;
696 715
             4) pleroma_add_emoji;;
697 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 723
         esac
699 724
     done
700 725
 }
@@ -1224,6 +1249,7 @@ function install_pleroma {
1224 1249
     sed -i '/config :pleroma, :media_proxy/!b;n;c####enabled: true,' $PLEROMA_DIR/config/config.exs
1225 1250
     sed -i 's|####enabled|  enabled|g' $PLEROMA_DIR/config/config.exs
1226 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 1254
     # set registrations open initially
1229 1255
     sed -i 's|registrations_open:.*|registrations_open: true,|g' $PLEROMA_DIR/config/config.exs
@@ -1235,6 +1261,7 @@ function install_pleroma {
1235 1261
     else
1236 1262
         sed -i 's|"media_proxy".*|"media_proxy": false,|g' $PLEROMA_DIR/priv/static/static/config.json
1237 1263
     fi
1264
+    sed -i 's|"chatDisabled":.*|"chatDisabled": true,|g' $PLEROMA_DIR/priv/static/static/config.json
1238 1265
 
1239 1266
     systemctl daemon-reload
1240 1267
     systemctl enable pleroma