Minor changes and corrections

Rewording of "deactivated" instead of "disabled", replacement of $profileurl and some changes to the stats output. Additionally some hints in the mail texts about notifiying by mail.

Signed-off-by: ij <ij@noreply.codeberg.org>
This commit is contained in:
ij 2023-12-13 20:05:13 +00:00
parent c31c0ab0e5
commit daf3cdff94

View File

@ -39,7 +39,7 @@ case $1 in
;;
*)
echo "Usage: "
echo "--init \t \t: create $0/.cleanup-mastodon-users.conf config file."
echo " --init \t: create $0/.cleanup-mastodon-users.conf config file."
echo " --dry-run \t: make a dry-run, no deletion will be done, no mails are sent."
echo " --cron \t: delete deactivated users in a regularly cron run step by step to avoid mass flooding."
echo " --dowhatimean \t: add this option if you really want to delete users."
@ -98,7 +98,7 @@ you have registered your account on ${LOCAL_DOMAIN} at ${registered} and last ti
If you want to continue to keep your Mastodon account on Nerdculture then please log in at least every 6 months via web browser to keep your account alive. Otherwise we assume that you don't want to use it anymore and will deactivate your account 7 months after your last login (and delete it later).
You can access your profile at ${profileurl} or you can cancel your account on your own when logged in at ${LOCAL_DOMAIN}removeme - however we would like to see you become an active user again and contribute to the Fediverse, but of course it's up to you.
You can access your profile at https://${LOCAL_DOMAIN}/@${username} or you can cancel your account on your own when logged in at https://${LOCAL_DOMAIN}/removeme - however we would like to see you become an active user again and contribute to the Fediverse, but of course it's up to you.
Sincerely,
your ${SITE} admins
@ -106,7 +106,6 @@ your ${SITE} admins
EOF
) | sed 's/_/\ /g' | /usr/bin/mail -s "The Fediverse misses you, ${username}!" -r "${SMTP_FROM_ADDRESS}" -- "${usermail}"
# add '-b "$SITEADMIN"' before the "--" above to receive BCC mails
#((num_notified++))
}
# notify user that the account has been deleted because of inactivity
@ -117,13 +116,15 @@ Dear ${dispname},
you have registered your account on ${LOCAL_DOMAIN} at ${registered} and last time you logged in was at ${lastlogin}.
Since you haven't reacted to the previous mails and didn't login again, your account including all your data has now been deactivated and will be deleted at a (random) later time.
Since you haven't reacted to the previous mails and didn't login again, your account including all your data has now been deactivated and will be deleted at a (random) later time (after ${DELDELIMIT}). Until then you can still request reactivattion from the admins. See ${LOCAL_DOMAIN}/about for contact information.
You will just receive the final confirmation mail of account deletion and no further mails!
Sincerely,
your ${SITE} admins
EOF
) | sed 's/_/\ /g' | /usr/bin/mail -s "Your account ${username} on ${SITE} has been deleted!" -r "${SMTP_FROM_ADDRESS}" -- "${usermail}"
) | sed 's/_/\ /g' | /usr/bin/mail -s "Your account ${username} on ${SITE} has been deactivated!" -r "${SMTP_FROM_ADDRESS}" -- "${usermail}"
# add '-b "$SITEADMIN"' before the "--" above to receive BCC mails
}
@ -137,6 +138,8 @@ you have registered your account on ${LOCAL_DOMAIN} at ${registered} and last ti
Since you haven't reacted to the previous mails and didn't login again, your account including all your data has now been deleted.
This is the last and final mail about your account on ${LOCAL_DOMAIN}
Sincerely,
your ${SITE} admins
@ -145,14 +148,7 @@ EOF
# add '-b "$SITEADMIN"' before the "--" above to receive BCC mails
}
# delete users that never logged in and never posted content
# filtering for "weeks" will result in accounts with 2 weeks old accounts,
# filter for just "week" will do the same after 1 week.
# same should apply to "month" and "months", but untested.
#for username in $( "${TOOTCTL}" user list active -c 10000 | grep 'never.*never' | grep weeks | awk '{print $2}') ; do
# select a.id, username, email, current_sign_in_at from accounts a, users u where domain is null and a.id=u.account_id and current_sign_in_at <'2019-01-01'
# main loop
case ${mode} in
"init")
initConfig
@ -169,15 +165,15 @@ case ${mode} in
exit 0
fi
echo "==================================="
echo "Total deactivated accounts: ${num_deactivated_total}"
echo "Number deactivated accounts over grace: ${num_deactivated_overgrace}"
echo "Deleting this many accounts: ${LIMIT_DELETE}"
echo "Account summary:"
echo "Total deactivated (>${UPPERLIMIT}): ${num_deactivated_total}"
echo "Over grace (${DELDELIMIT}): ${num_deactivated_overgrace}"
echo "Deleting at once: ${LIMIT_DELETE}"
echo "==================================="
for u in $(psql -U "${DB_USER}" -w -h "${DB_HOST}" -p "${DB_PORT}" -t "${DB_NAME}" -c "select concat(username||';'||display_name||';'||email||';'||to_char(a.created_at, 'YYYY-MM-DD')||';'||to_char(current_sign_in_at,'YYYY-MM-DD')) from accounts a, users u where disabled is true and a.id=u.account_id and current_sign_in_at < now()-'${DELDELIMIT}'::interval and username not in ($SQLPROTECTEDUSERS) order by current_sign_in_at limit ${LIMIT_DELETE}" | tr -d " " ); do
#echo ${u}
username=$(echo "${u}" | awk -F ";" '{print $1}')
dispname=$(echo "${u}" | awk -F ";" '{print $2}')
profileurl="https://nerdculture.de/@${username}"
usermail=$(echo "${u}" | awk -F ";" '{print $3}')
registered=$(echo "${u}" | awk -F ";" '{print $4}')
lastlogin=$(echo "${u}" | awk -F ";" '{print $5}')
@ -243,7 +239,6 @@ case ${mode} in
#echo ${u}
username=$(echo "${u}" | awk -F ";" '{print $1}')
dispname=$(echo "${u}" | awk -F ";" '{print $2}')
profileurl="https://nerdculture.de/@${username}"
usermail=$(echo "${u}" | awk -F ";" '{print $3}')
registered=$(echo "${u}" | awk -F ";" '{print $4}')
lastlogin=$(echo "${u}" | awk -F ";" '{print $5}')
@ -271,7 +266,7 @@ case ${mode} in
notifyUserDisable
#echo "deleted."
elif [ "${mode}" = "dryrun" ]; then
echo "will be disabled, but is skipped because of dryrun."
echo "will be deactivated, but is skipped because of dryrun."
fi
num_disabled=$((num_disabled+1))
exit
@ -293,6 +288,6 @@ echo "==================================="
echo "Starting time : ${STARTDATE}"
echo "Ending time : ${ENDDATE}"
echo "Notified Users: $num_notified"
echo "Disabled Users: $num_disabled"
echo "Deleted Users : $num_deactivated_total"
echo "Deactivated : $num_disabled"
echo "To be deleted : $num_deactivated_total"
echo "==================================="