From c5abcf078a8ece12944e39ba4d786d84fc5facba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Fri, 8 Jul 2016 01:07:55 +0200 Subject: [PATCH] fix bash version of sieve-filter --- conversations/emails.py | 2 +- conversations/post-mail.sh | 9 +++++++++ conversations/sieve-filter.sh | 5 ----- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100755 conversations/post-mail.sh delete mode 100755 conversations/sieve-filter.sh diff --git a/conversations/emails.py b/conversations/emails.py index c7f2ff0..74cd07c 100644 --- a/conversations/emails.py +++ b/conversations/emails.py @@ -22,7 +22,7 @@ def email_recv(request): or not hasattr(settings, 'REPLY_KEY'): return HttpResponse(status=501) # Not Implemented - key = request.POST.get('key') + key = request.POST.get('key').strip() if key != settings.REPLY_KEY: raise PermissionDenied diff --git a/conversations/post-mail.sh b/conversations/post-mail.sh new file mode 100755 index 0000000..78ed968 --- /dev/null +++ b/conversations/post-mail.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +# Usage: cat email.txt | post-mail.sh https://example.org/conversations/recv/ /etc/ponyconf/key.txt +# The file /etc/ponyconf/key.txt should contain the value of the django setting REPLY_KEY. + +url="$1" +key="$2" + +curl ${url} -F 'key=<${key}' -F 'file=@-;filename="email"' diff --git a/conversations/sieve-filter.sh b/conversations/sieve-filter.sh deleted file mode 100755 index 81fcbb9..0000000 --- a/conversations/sieve-filter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -url=${@#*\@} -key=${@%\@*} -curl ${url} -d key=${key} -d -