From d56f5a014630cfffcf722fe5789102cf51abf1e3 Mon Sep 17 00:00:00 2001 From: Freddy0 <72572280+Freddy-0@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:30:32 +0200 Subject: [PATCH] Added new example for sending messages via ntfy with a Paperparrot link --- Post-Consume-Script-Examples.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Post-Consume-Script-Examples.md b/Post-Consume-Script-Examples.md index 94df022..f0987f5 100644 --- a/Post-Consume-Script-Examples.md +++ b/Post-Consume-Script-Examples.md @@ -79,4 +79,25 @@ if __name__ == "__main__": timeout=timeout, ) resp.raise_for_status() +``` + + +## Send new document message via ntfy + Paperparrot + +```python +#!/usr/bin/env python3 + +import os, requests, json + +DOCUMENT_ID = os.getenv('DOCUMENT_ID') +USER = os.getenv('DOCUMENT_OWNER') + +PAPERPARROT_URL = f"paperparrot://documents/{DOCUMENT_ID}" +NTFY_URL = "https://ntfy.example.com/" + +requests.post(NTFY_URL, data=json.dumps({ + "topic": USER, + "message": f"Hi, {USER}, a Document has been added", + "actions": [{"action": "view", "label": "Open", "url": PAPERPARROT_URL}] +}), headers={"Click": PAPERPARROT_URL}) ``` \ No newline at end of file