From b9cce5d12baa40deb21ab4f36be19e3a41e18ad4 Mon Sep 17 00:00:00 2001 From: 玄猫 Date: Sun, 19 Jan 2025 20:34:42 +0800 Subject: feat(webhook): Implement webhook functionality for bookmark events (#852) * feat(webhook): Implement webhook functionality for bookmark events - Added WebhookWorker to handle webhook requests. - Integrated webhook triggering in crawlerWorker after video processing. - Updated main worker initialization to include WebhookWorker. - Enhanced configuration to support webhook URLs, token, and timeout. - Documented webhook configuration options in the documentation. - Introduced zWebhookRequestSchema for validating webhook requests. * feat(webhook): Update webhook handling and configuration - Changed webhook operation type from "create" to "crawled" in crawlerWorker and documentation. - Enhanced webhook retry logic in WebhookWorker to support multiple attempts. - Updated Docker configuration to include new webhook environment variables. - Improved validation for webhook configuration in shared config. - Adjusted zWebhookRequestSchema to reflect the new operation type. - Updated documentation to clarify webhook configuration options and usage. * minor modifications --------- Co-authored-by: Mohamed Bassem --- docs/docs/03-configuration.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'docs') diff --git a/docs/docs/03-configuration.md b/docs/docs/03-configuration.md index 82438dbf..bf326aff 100644 --- a/docs/docs/03-configuration.md +++ b/docs/docs/03-configuration.md @@ -95,3 +95,36 @@ Hoarder uses [tesseract.js](https://github.com/naptha/tesseract.js) to extract t | OCR_CACHE_DIR | No | $TEMP_DIR | The dir where tesseract will download its models. By default, those models are not persisted and stored in the OS' temp dir. | | OCR_LANGS | No | eng | Comma separated list of the language codes that you want tesseract to support. You can find the language codes [here](https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html). Set to empty string to disable OCR. | | OCR_CONFIDENCE_THRESHOLD | No | 50 | A number between 0 and 100 indicating the minimum acceptable confidence from tessaract. If tessaract's confidence is lower than this value, extracted text won't be stored. | + +## Webhook Configs + +You can use webhooks to trigger actions when bookmarks are changed ( only support _crawled_ now ). + +| Name | Required | Default | Description | +| ------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | +| WEBHOOK_URLS | No | | The urls of the webhooks to trigger, separated by commas. | +| WEBHOOK_TOKEN | No | | The token to use for authentication. Will appears in the Authorization header as Bearer token. | +| WEBHOOK_TIMEOUT_SEC | No | 5 | The timeout for the webhook request in seconds. | +| WEBHOOK_RETRY_TIMES | No | 3 | The number of times to retry the webhook request. | + +:::info + +- If a url is add to hoarder , after it is crawled, the webhook will be triggered. +- The WEBHOOK_TOKEN is used for authentication. It will appear in the Authorization header as Bearer token. + ``` + Authorization: Bearer + ``` +- The webhook will be triggered with the job id (used for idempotence), bookmark id, bookmark type, the user id, the url and the operation in JSON format in the body. + + ```json + { + "jobId": 123, + "type": "link", + "bookmarkId": "exampleBookmarkId", + "userId": "exampleUserId", + "url": "https://example.com", + "operation": "crawled" + } + ``` + + ::: -- cgit v1.2.3-70-g09d2