Browse Source

Mail über global-cube.com

gc-server3 1 year ago
parent
commit
fe91de6944
2 changed files with 11 additions and 4 deletions
  1. 7 0
      fehlerbericht/config.py
  2. 4 4
      fehlerbericht/mail_import.py

+ 7 - 0
fehlerbericht/config.py

@@ -7,3 +7,10 @@ MAILBOX = {
     "password": "(6QNLU=7m3R?f2?6]JO4WH(K",
     "folder": "INBOX",  # "Test",  "INBOX"
 }
+
+MAILBOX = {
+    "server": "mail.global-cube.com",
+    "user": "status",
+    "password": "VtAgcw&(L6Sa%R<L",
+    "folder": "INBOX",
+}

+ 4 - 4
fehlerbericht/mail_import.py

@@ -41,14 +41,14 @@ class MailImport:
 
     def get_status_message(self, msg: MailMessage) -> StatusMeldung:
         subject = msg.subject.split(";")
-        if len(subject) < 5:
-            print(msg.subject)
-            return None
-
         attachments = dict([(att.filename, att.payload) for att in msg.attachments if att.size > 0])
         fehlerbericht_json = json.loads(attachments.get("fehlerbericht.json", "[]"))
         fehlerbericht_import = json.dumps(fehlerbericht_json)
 
+        if len(subject) < 5 or len(attachments) == 0 or len(fehlerbericht_json) == 0:
+            print(msg.subject)
+            return None
+
         aufgabe = ""
         if len(subject) > 5:
             if subject[5][-4:] == ".bat":