From d000eeacf7823384692aad827ef81f3dd4b14388 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Tue, 27 Nov 2018 20:38:14 +0000 Subject: [PATCH] Remove from xmpp muc filtered words using unignore command --- src/freedombone-unignore | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/freedombone-unignore b/src/freedombone-unignore index 8f01bd89d..6e3b3aacf 100755 --- a/src/freedombone-unignore +++ b/src/freedombone-unignore @@ -6,8 +6,8 @@ # # Freedom in the Cloud # -# Removes an ignore rule for either an email address -# or text in the subject line +# Removes an ignore rule for either an email address or text in the +# subject line or from xmpp MUC filtered words # # License # ======= @@ -32,6 +32,7 @@ PROJECT_NAME='freedombone' export TEXTDOMAIN=${PROJECT_NAME}-unignore export TEXTDOMAINDIR="/usr/share/locale" +XMPP_CONFIG=/etc/prosody/prosody.cfg.lua MYUSERNAME=$USER EMAIL_ADDRESS= SUBJECT_TEXT= @@ -96,6 +97,27 @@ if [ "$ALL_TEXT" ]; then if grep -q "Ignore rule for words '$ALL_TEXT'" "$PM"; then sed -i "/# Ignore rule for words '$ALL_TEXT'/,/# End of ignore words rule/d" "$PM" fi + + if [ -f "$XMPP_CONFIG" ]; then + if grep -q 'filter_words =' "$XMPP_CONFIG"; then + if ! grep -q 'filter_words = {}' "$XMPP_CONFIG"; then + curr_filter_words=$(grep 'filter_words =' "$XMPP_CONFIG") + if [ "$curr_filter_words" ]; then + if [[ "$curr_filter_words" == *",\"${ALL_TEXT}\""* ]]; then + sed -i "s|,\"${ALL_TEXT}\"||g" "$XMPP_CONFIG" + else + if [[ "$curr_filter_words" == *"\"${ALL_TEXT}\","* ]]; then + sed -i "s|\"${ALL_TEXT}\",||g" "$XMPP_CONFIG" + else + if [[ "$curr_filter_words" == *" \"${ALL_TEXT}\" "* ]]; then + sed -i "s| \"${ALL_TEXT}\" ||g" "$XMPP_CONFIG" + fi + fi + fi + fi + fi + fi + fi fi # unignore an email address -- GitLab