From 9870b214a757b9c14280aaf8f01fec10154693fe Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Mon, 13 Jan 2025 18:33:45 +0100
Subject: [PATCH] =?UTF-8?q?DSN:=20Skript=20na=20pos=C3=ADl=C3=A1n=C3=AD=20?=
 =?UTF-8?q?DSN=20do=20API?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 bin/send-dsn | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 bin/send-dsn

diff --git a/bin/send-dsn b/bin/send-dsn
new file mode 100755
index 00000000..e3cb49c2
--- /dev/null
+++ b/bin/send-dsn
@@ -0,0 +1,22 @@
+#!/usr/bin/python3
+# Tento skript se volá při doručování pošty (například pomocí "execute" v Sieve)
+# a předá mail webové části OSMO přes /api/email-dsn.
+
+import requests
+from requests.exceptions import RequestException
+import sys
+
+if len(sys.argv) != 2:
+    print('Arguments: <URL of OSMO root>/', file=sys.stderr)
+    sys.exit(1)
+
+osmo_url = sys.argv[1]
+mail = sys.stdin.buffer.read()
+
+try:
+    reply = requests.post(f'{osmo_url}api/email-dsn', data=mail, timeout=30)
+except RequestException:
+    sys.exit(1)
+
+if reply.status_code != 200:
+    sys.exit(1)
-- 
GitLab