[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [trac-email/master] Polish script



commit d3ce4bca377b5f6a06173e1bbc8176752112f832
Author: hiromipaw <hiro@xxxxxxxxxxxxxx>
Date:   Wed Dec 14 15:34:46 2016 +0100

    Polish script
---
 notify.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/notify.py b/notify.py
index 5d8f886..cf0bae0 100755
--- a/notify.py
+++ b/notify.py
@@ -14,14 +14,15 @@ def read_message():
 def verify_email_signature(message, user):
     gpg = gnupg.GPG(gnupghome='/home/tracadm/.gnupg')
     verified = gpg.verify(message)
-    if verified.trust_level is not None and verified.trust_level >= verified.TRUST_UNDEFINED:
+
+    if verified.trust_level is not None and verified.trust_level >= 0 and verified.key_status is None:
         with open('/home/tracadm/bin/map', 'rb') as csvfile:
             keysreader = csv.reader(csvfile, delimiter=' ')
             for row in keysreader:
                 k = row[0]
                 u = row[1].strip()
                 if k == verified.fingerprint and u == user:
-                    return True
+                    return verified
 
 def get_message_body(message):
     if message.is_multipart():
@@ -86,13 +87,16 @@ with open('/home/tracadm/log/test.log', 'w') as f:
     user = msg['From'].split('@')[0]
 
     verified = verify_email_signature(msg.as_string(), user)
+
     if verified:
+        f.write('GPG verified\n')
+
         # Find or create ticket
-        f.write('GPG verified')
         tkt = find_or_create_ticket(msg, env)
+
         if tkt:
             f.write(str(tkt))
         else:
-            f.write('Could not create Ticket. I should send an email back I suppose')
+            f.write('Could not create Ticket. I should send an email back I suppose \n')
     else:
-        f.write('Could not verify GPG. I should send an email back I suppose')
+        f.write('Could not verify GPG. I should send an email back I suppose \n')

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits