notify-scripts: hash the object ids (#8689)

This commit is contained in:
Simon L.
2026-09-16 11:30:17 +02:00
committed by GitHub
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" | sha256sum | cut -c1-64)"
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" | sha256sum | cut -c1-64)"
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!"