Kaynağa Gözat

Improve user blocking in pleroma

Bob Mottram 6 yıl önce
ebeveyn
işleme
67e6ceadb7
1 değiştirilmiş dosya ile 16 ekleme ve 8 silme
  1. 16
    8
      src/freedombone-app-pleroma

+ 16
- 8
src/freedombone-app-pleroma Dosyayı Görüntüle

@@ -140,6 +140,14 @@ function create_pleroma_blocklist {
140 140
       echo '                fi';
141 141
       echo "                websub_server_subscriptions_query=\"\${websub_server_subscriptions_query} callback like '%\${blocked}%'\"";
142 142
       echo '                websub_server_subscriptions_updated=1';
143
+      echo '            else';
144
+
145
+      echo "                curr_user_query=\"SELECT nickname FROM users where nickname ilike '%\${blocked}%'\"";
146
+      echo "                curr_user_present=\$(sudo -u postgres psql -d pleroma -c \"\$curr_user_query\")";
147
+      echo "                if [[ \"\$curr_user_present\" != *'(0 '* ]]; then";
148
+      echo "                    cd $PLEROMA_DIR";
149
+      echo "                    sudo -u pleroma mix deactivate_user \${blocked}";
150
+      echo '                fi';
143 151
       echo '            fi';
144 152
       echo '        fi';
145 153
       echo '    fi';
@@ -158,14 +166,14 @@ function create_pleroma_blocklist {
158 166
       echo '    fi';
159 167
       echo 'fi';
160 168
       echo '';
161
-      echo 'cd /etc/postgresql';
162
-      echo "if [ \$objects_updated ]; then";
163
-      echo "    sudo -u postgres psql -d pleroma -c \"\$objects_query\"";
164
-      echo "    sudo -u postgres psql -d pleroma -c \"\$users_query\"";
165
-      echo 'fi';
166
-      echo "if [ \$websub_server_subscriptions_updated ]; then";
167
-      echo "    sudo -u postgres psql -d pleroma -c \"\$websub_server_subscriptions_query\"";
168
-      echo 'fi';
169
+      echo '#cd /etc/postgresql';
170
+      echo "#if [ \$objects_updated ]; then";
171
+      echo "#    sudo -u postgres psql -d pleroma -c \"\$objects_query\"";
172
+      echo "#    sudo -u postgres psql -d pleroma -c \"\$users_query\"";
173
+      echo '#fi';
174
+      echo "#if [ \$websub_server_subscriptions_updated ]; then";
175
+      echo "#    sudo -u postgres psql -d pleroma -c \"\$websub_server_subscriptions_query\"";
176
+      echo '#fi';
169 177
       echo 'rm /tmp/pleroma-blocking.lock'; } > $blocking_script_file
170 178
 
171 179
     chmod +x $blocking_script_file