attach files

This commit is contained in:
Antonio J. Delgado 2023-03-20 23:00:15 +02:00
parent bb24590a17
commit fbb724b12e

View file

@ -230,12 +230,21 @@ if [ "${mail_alert}" == "true" ]; then
fi
if [ -n "${ntfy_server}" ]; then
ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}" # , \"email\": \"${email_destination}\" }"
if [ -n "${file}" ]; then
ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\", \"filename\": \"${file}\" }"
else
ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}"
fi
ntfy_password="$(cat "${ntfy_password_file}")"
message "Sending event to ntfy server '${ntfy_server}/motion_detection' ..."
message "Data: ${ntfy_data}"
curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}"
return_code=$?
if [ -n "${file}" ]; then
curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}"
return_code=$?
else
curl -s "${ntfy_server}" -T "${file}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}"
return_code=$?
fi
if [ $return_code != 0 ]; then
message "Error ${return_code} publishing in ntfy server '${ntfy}'"
fi