|
@@ -85,19 +85,42 @@ function create_pleroma_blocklist {
|
85
|
85
|
echo ' fi' >> $blocking_script_file
|
86
|
86
|
echo 'fi' >> $blocking_script_file
|
87
|
87
|
echo 'touch /tmp/pleroma-blocking.lock' >> $blocking_script_file
|
88
|
|
- echo 'cd /etc/postgresql' >> $blocking_script_file
|
|
88
|
+ echo 'objects_query="DELETE FROM objects WHERE"' >> $blocking_script_file
|
|
89
|
+ echo 'objects_updated=' >> $blocking_script_file
|
|
90
|
+ echo 'users_query="DELETE FROM users WHERE"' >> $blocking_script_file
|
|
91
|
+ echo 'websub_server_subscriptions_query="DELETE FROM websub_server_subscriptions WHERE"' >> $blocking_script_file
|
|
92
|
+ echo 'websub_server_subscriptions_updated=' >> $blocking_script_file
|
89
|
93
|
echo 'while read blocked; do' >> $blocking_script_file
|
90
|
94
|
echo ' if [[ "$blocked" == *"."* || "$blocked" == *"@"* ]]; then' >> $blocking_script_file
|
91
|
95
|
echo ' if [ ${#blocked} -gt 4 ]; then' >> $blocking_script_file
|
92
|
|
- echo " sudo -u postgres psql -d pleroma -c \"DELETE FROM objects WHERE data->>'content' ilike '%\${blocked}%' or data->>'actor' ilike '%\${blocked}%' or data->>'to' ilike '%\${blocked}%' or data->>'id' ilike '%\${blocked}%' or data->>'external_url' ilike '%\${blocked}%'\"" >> $blocking_script_file
|
93
|
|
- echo " sudo -u postgres psql -d pleroma -c \"DELETE FROM users WHERE nickname ilike '%\${blocked}%'\"" >> $blocking_script_file
|
|
96
|
+ echo ' if [ $objects_updated ]; then' >> $blocking_script_file
|
|
97
|
+ echo ' objects_query="${objects_query} or"' >> $blocking_script_file
|
|
98
|
+ echo ' users_query="${users_query} or"' >> $blocking_script_file
|
|
99
|
+ echo ' fi' >> $blocking_script_file
|
|
100
|
+ echo " objects_query=\"\${objects_query} data->>'content' ilike '%\${blocked}%' or data->>'actor' ilike '%\${blocked}%' or data->>'to' ilike '%\${blocked}%' or data->>'id' ilike '%\${blocked}%' or data->>'external_url' ilike '%\${blocked}%'\"" >> $blocking_script_file
|
|
101
|
+ echo " users_query=\"\${users_query} nickname ilike '%\${blocked}%'\"" >> $blocking_script_file
|
|
102
|
+ echo ' objects_updated=1' >> $blocking_script_file
|
94
|
103
|
echo ' if [[ "$blocked" != *"@"* ]]; then' >> $blocking_script_file
|
95
|
|
- echo " sudo -u postgres psql -d pleroma -c \"DELETE FROM websub_server_subscriptions WHERE callback like '%\${blocked}%'\"" >> $blocking_script_file
|
|
104
|
+ echo ' if [ $websub_server_subscriptions_updated ]; then' >> $blocking_script_file
|
|
105
|
+ echo ' websub_server_subscriptions_query="${websub_server_subscriptions_query} or"' >> $blocking_script_file
|
|
106
|
+ echo ' fi' >> $blocking_script_file
|
|
107
|
+ echo " websub_server_subscriptions_query=\"\${websub_server_subscriptions_query} callback like '%\${blocked}%'\"" >> $blocking_script_file
|
|
108
|
+ echo ' websub_server_subscriptions_updated=1' >> $blocking_script_file
|
96
|
109
|
echo ' fi' >> $blocking_script_file
|
97
|
110
|
echo ' fi' >> $blocking_script_file
|
98
|
111
|
echo ' fi' >> $blocking_script_file
|
99
|
|
- echo "done </root/${PROJECT_NAME}-firewall-domains.cfg" >> $blocking_script_file
|
|
112
|
+ echo 'done </root/freedombone-firewall-domains.cfg' >> $blocking_script_file
|
|
113
|
+ echo '' >> $blocking_script_file
|
|
114
|
+ echo 'cd /etc/postgresql' >> $blocking_script_file
|
|
115
|
+ echo 'if [ $objects_updated ]; then' >> $blocking_script_file
|
|
116
|
+ echo ' sudo -u postgres psql -d pleroma -c "$objects_query"' >> $blocking_script_file
|
|
117
|
+ echo ' sudo -u postgres psql -d pleroma -c "$users_query"' >> $blocking_script_file
|
|
118
|
+ echo 'fi' >> $blocking_script_file
|
|
119
|
+ echo 'if [ $websub_server_subscriptions_updated ]; then' >> $blocking_script_file
|
|
120
|
+ echo ' sudo -u postgres psql -d pleroma -c "$websub_server_subscriptions_query"' >> $blocking_script_file
|
|
121
|
+ echo 'fi' >> $blocking_script_file
|
100
|
122
|
echo 'rm /tmp/pleroma-blocking.lock' >> $blocking_script_file
|
|
123
|
+
|
101
|
124
|
chmod +x $blocking_script_file
|
102
|
125
|
|
103
|
126
|
if ! grep -q "$blocking_script_file" /etc/crontab; then
|