forgehook-notify is database-agnostic

This commit is contained in:
southerntofu 2020-04-28 14:20:40 +02:00
parent f5930bf2dd
commit 5493d4de22
1 changed files with 3 additions and 10 deletions

View File

@ -2,18 +2,10 @@
if [[ $EUID != 0 ]]; then
# We're not root... yet!
# Let's not forget to define the db while we have forgehook $USER
# TODO: replace with ~/database
db=$HOME/webhooks
sudo forgehook-notify $@
exit $?
fi
# If the $db is empty/unset, we have a logic bug somewhere!
if [ -z $db ]; then
echo "FATAL ERROR: Could not find forgehook database (BUG)"
fi
# We only take one argument!
if [[ $# != 1 ]]; then
echo "FATAL ERROR: forgehook-notify can't deal with $# argument(s) (BUG)"
@ -31,9 +23,10 @@ rhex="$(echo -n "$r" | base64)"
shopt -s nullglob
# Iterate over the hex-encoded URL's subscriptions
for i in $db/"$rhex".*; do
IFS= echo "$(forgehook list "$1")" | while read -r user; do
#for i in $db/"$rhex".*; do
# Strip $rhex prefix
user="$(basename "$i")"
user="$(basename "$user")"
user="${user#$rhex.}"
sudo -u "$user" forgehook-trigger "$1"