mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-09-18 09:17:24 +00:00
notify-scripts: hash the object ids
Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
@@ -13,6 +13,10 @@ fi
|
||||
SUBJECT="$1"
|
||||
MESSAGE="$2"
|
||||
|
||||
# The object-id is limited to 64 characters, so hash the subject to get a
|
||||
# stable identifier of fixed length that is unique per subject.
|
||||
OBJECT_ID="$(printf '%s' "$SUBJECT" | md5sum | cut -d ' ' -f1)"
|
||||
|
||||
if [ "$("${COMMAND[@]}" config:app:get notifications enabled)" = "no" ]; then
|
||||
echo "Cannot send notification as notification app is not enabled."
|
||||
exit 1
|
||||
@@ -24,7 +28,7 @@ mapfile -t NC_USERS <<< "$NC_USERS"
|
||||
for user in "${NC_USERS[@]}"
|
||||
do
|
||||
echo "Posting '$SUBJECT' to: $user"
|
||||
"${COMMAND[@]}" notification:generate "$user" "$NC_DOMAIN: $SUBJECT" -l "$MESSAGE" --object-type='update' --object-id="$SUBJECT"
|
||||
"${COMMAND[@]}" notification:generate "$user" "$NC_DOMAIN: $SUBJECT" -l "$MESSAGE" --object-type='update' --object-id="$OBJECT_ID"
|
||||
done
|
||||
|
||||
echo "Done!"
|
||||
|
||||
@@ -13,6 +13,10 @@ fi
|
||||
SUBJECT="$1"
|
||||
MESSAGE="$2"
|
||||
|
||||
# The object-id is limited to 64 characters, so hash the subject to get a
|
||||
# stable identifier of fixed length that is unique per subject.
|
||||
OBJECT_ID="$(printf '%s' "$SUBJECT" | md5sum | cut -d ' ' -f1)"
|
||||
|
||||
if [ "$("${COMMAND[@]}" config:app:get notifications enabled)" = "no" ]; then
|
||||
echo "Cannot send notification as notification app is not enabled."
|
||||
exit 1
|
||||
@@ -32,7 +36,7 @@ done
|
||||
for admin in "${NC_ADMIN_USER[@]}"
|
||||
do
|
||||
echo "Posting '$SUBJECT' to: $admin"
|
||||
"${COMMAND[@]}" notification:generate "$admin" "$NC_DOMAIN: $SUBJECT" -l "$MESSAGE" --object-type='update' --object-id="$SUBJECT"
|
||||
"${COMMAND[@]}" notification:generate "$admin" "$NC_DOMAIN: $SUBJECT" -l "$MESSAGE" --object-type='update' --object-id="$OBJECT_ID"
|
||||
done
|
||||
|
||||
echo "Done!"
|
||||
|
||||
Reference in New Issue
Block a user