[GH-ISSUE #287] required events notification #149

Closed
opened 2026-04-08 16:50:41 +03:00 by zhus · 2 comments
Owner

Originally created by @fj0r on GitHub (Nov 9, 2023).
Original GitHub issue: https://github.com/sigoden/dufs/issues/287

Specific Demand

Allows webhook notifications to be sent when files are created, modified, and deleted (optional indexing, download event notifications)

Easy to integrate with other systems, such as CI/CD

Implement Suggestion

event data like this:

{
    type:  update|modify|delete|index|download
    datetime: <now>
    path: path/to
    file:  example
    ext: txt|json|....
    is_dir: false
    size: ...
    client_ip: 1.2.3.4
    ua: ....
}
Originally created by @fj0r on GitHub (Nov 9, 2023). Original GitHub issue: https://github.com/sigoden/dufs/issues/287 ## Specific Demand Allows webhook notifications to be sent when files are created, modified, and deleted (optional indexing, download event notifications) Easy to integrate with other systems, such as CI/CD ## Implement Suggestion event data like this: ``` { type: update|modify|delete|index|download datetime: <now> path: path/to file: example ext: txt|json|.... is_dir: false size: ... client_ip: 1.2.3.4 ua: .... } ```
zhus closed this issue 2026-04-08 16:50:41 +03:00
Author
Owner

@fj0r commented on GitHub (Nov 9, 2023):

It is best to customize the notification format and support filtering, such as simulating github events

notification:
  - events:
        - update
        - modify
        - delete
    prefix:
        - /a/b/c
        - /d/e
    template:  commit.json
  - events:
        - update
    prefix:
        - /
    template:  default.json
# commit.json
{
    "type":  "commit",
    "message": "dufs {{client_ip}} commit {{action}} {{path}}/{{file}}.{{ext}}"
}
# default.json
{
    "type":  "{{type}}",
    "datetime": "{{datetime}}",
    ....
}
<!-- gh-comment-id:1803117147 --> @fj0r commented on GitHub (Nov 9, 2023): It is best to customize the notification format and support filtering, such as simulating github events ```yaml notification: - events: - update - modify - delete prefix: - /a/b/c - /d/e template: commit.json - events: - update prefix: - / template: default.json ``` ```json # commit.json { "type": "commit", "message": "dufs {{client_ip}} commit {{action}} {{path}}/{{file}}.{{ext}}" } # default.json { "type": "{{type}}", "datetime": "{{datetime}}", .... } ```
Author
Owner

@sigoden commented on GitHub (Nov 9, 2023):

I will not implement this feature within dufs.

You can achieve this requirement through other tools.

For example, inotify-tools is specifically for doing this.

 #!/bin/bash

 # Path to the directory or file you want to watch
 WATCH_PATH="path_to_watch"

 # Webhook URL
 WEBHOOK_URL="your_webhook_url"

 # Watch for changes in the directory or file (modify, move, create, delete)
 inotifywait -m -e modify -e move -e create -e delete --format '%w%f' "$WATCH_PATH" | while read FILE
 do
     # Execute a curl command to send a POST request to your webhook
     # You might need to add additional flags to curl and payload content based on your webhook requirements
     curl -X POST -H "Content-Type: application/json" -d "{\"message\": \"File changed: $FILE\"}" "$WEBHOOK_URL"
 done
<!-- gh-comment-id:1803126387 --> @sigoden commented on GitHub (Nov 9, 2023): I will not implement this feature within dufs. You can achieve this requirement through other tools. For example, inotify-tools is specifically for doing this. ```bash #!/bin/bash # Path to the directory or file you want to watch WATCH_PATH="path_to_watch" # Webhook URL WEBHOOK_URL="your_webhook_url" # Watch for changes in the directory or file (modify, move, create, delete) inotifywait -m -e modify -e move -e create -e delete --format '%w%f' "$WATCH_PATH" | while read FILE do # Execute a curl command to send a POST request to your webhook # You might need to add additional flags to curl and payload content based on your webhook requirements curl -X POST -H "Content-Type: application/json" -d "{\"message\": \"File changed: $FILE\"}" "$WEBHOOK_URL" done ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#149