notify-scripts: hash the object ids

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L.
2026-09-14 11:10:15 +02:00
parent 62aceb84ad
commit 3fcce2e8a2
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -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!"
+5 -1
View File
@@ -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!"