Skip to content

Instantly share code, notes, and snippets.

@crt0mega
Last active Jan 11, 2021
Embed
What would you like to do?
Hubzilla de-Zlaxyfier
#!/bin/bash
#######################
# Database connection #
#######################
declare DB_NAME="hubzilla"
declare DB_HOST="localhost"
declare DB_PORT="3306"
declare DB_USER="user"
declare DB_PASS="pass"
###################
# Array of Zlaxes #
###################
declare -a SPAMMERS=(
"vm66%@diaspora.ruhrmail.de"
"ivan_exlax@pod.dapor.net"
"zlax@%"
"zlaxy@%"
"zlaxyizlax@%"
"zlax%@d.consumium.org"
"vm66%@mondiaspora.net"
"vm66%@diaspora.club"
"vm66%@nerdpol.ch"
"vm66%@diasp.org"
"vm66%@diaspora.asrun.eu"
"vm66%@diaspora-fr.org"
"mrd_ill_be_back@neptune.jerrylumpkins.me"
"mrd_ill_be_back@protagio.social"
"mrd_ill_be_back@pod.dapor.net"
"christophs@nota.404.mn"
"christophs@podbay.net"
"atomjack@podbay.net"
"hackbyte@pod.dapor.net"
"hackbyte@diaspora.club"
"pufcorn@podbay.net"
"0mega@podbay.net"
"florida_ted@pod.dapor.net"
"jlumpkins@podbay.net"
"jlumpkins@pod.dapor.net"
"jlumpkins@spora.grin.hu"
"wurstaufbrot@pod.dapor.net"
"wurstaufbrot@pod.tchncs.de"
"deusfigendi@neptune.jerrylumpkins.me"
"owlmagic@pod.tchncs.de"
"kennychaffin@pod.tchncs.de"
"johnhummel@diasporing.ch"
)
####################################
# Extermination of Zlaxes' actions #
####################################
for SPAM in "${SPAMMERS[@]}"
do
echo "Preparing to remove items from handle $SPAM ..."
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "UPDATE item SET item_pending_remove = '1' WHERE author_xchan LIKE '$SPAM'; SELECT ROW_COUNT()"
#TODO: Add handle to serialized array in config where cat="system" and k="blacklisted_channels"
done
#################################################
# Finally remove all marked items from database #
#################################################
echo "All items have been marked for deletion and won't be visible anymore. If you wish to delete them permamently, type YES."
read REMOVAL
if [ "$REMOVAL" = "YES" ]; then
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "DELETE from item WHERE item_pending_remove = '1'; SELECT ROW_COUNT()"
fi
########################
# Remove notifications #
########################
for SPAM in "${SPAMMERS[@]}"
do
POD=$(echo -e "$SPAM" | cut -f2 -d"@")
USR=$(echo -e "$SPAM" | cut -f1 -d"@")
URL="htt%://$POD/u/$USR"
echo "Removing notifications from handle $SPAM ..."
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "DELETE FROM notify WHERE url LIKE '$URL'; SELECT ROW_COUNT()"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment