Swagger file update

This commit is contained in:
Dominik Chilla 2018-12-23 22:56:16 +01:00
parent 76acc94391
commit 937b805779
2 changed files with 65 additions and 40 deletions

View File

@ -1,4 +1,4 @@
import json,sys,os,logging,re,magic
import json, sys,os,logging,re,magic
import email,email.header,email.message
from GulagDB import GulagDB,GulagDBException
from GulagMailbox import IMAPmailbox,IMAPmailboxException
@ -90,7 +90,8 @@ class Gulag:
r5321_from = r5321_from.replace(">","")
r5321_rcpts = None
try:
r5321_rcpts = email.header.decode_header(msg['X-Envelope-To-Blocked'])[0][0]
r5321_rcpts = email.header.decode_header(
msg['X-Envelope-To-Blocked'])[0][0]
except:
logging.warning(whoami(self) +
"Failed to extract envelope recipients! Skipping mail"
@ -130,10 +131,12 @@ class Gulag:
# über die mailbox_id sowie die imap_uid mehrfach referenziert.
for r5321_rcpt in r5321_rcpts.split(","):
quarmail_id = self.db.add_quarmail({
'mx_queue_id': mx_queue_id, 'env_from': r5321_from, 'env_rcpt': r5321_rcpt,
'hdr_cf': x_spam_status, 'hdr_from': r5322_from, 'hdr_subject': subject,
'hdr_msgid': msg_id, 'hdr_date': date, 'cf_meta': 'cf_meta',
'mailbox_id': 'quarantine@zwackl.de', 'imap_uid': uid, 'msg_size': msg_size
'mx_queue_id': mx_queue_id, 'env_from': r5321_from,
'env_rcpt': r5321_rcpt, 'hdr_cf': x_spam_status,
'hdr_from': r5322_from, 'hdr_subject': subject,'hdr_msgid': msg_id,
'hdr_date': date, 'cf_meta': 'cf_meta',
'mailbox_id': 'quarantine@zwackl.de', 'imap_uid': uid,
'msg_size': msg_size
})
logging.info(whoami(self) + "QuarMail (%s) imported" % (quarmail_id))
quarmail_ids.append(quarmail_id)
@ -167,7 +170,9 @@ class Gulag:
ctype = part.get_content_type()
if(ctype == 'text/plain' or ctype == 'text/html'):
curis = {}
curis = extract_uris(part.get_payload(decode=True).decode("utf-8","replace"))
curis = extract_uris(
part.get_payload(decode=True).decode("utf-8","replace")
)
if(len(curis) > 0):
logging.info(whoami(self) + "CURIS: " + str(curis))
uris = {**uris, **curis}
@ -178,7 +183,8 @@ class Gulag:
for attachment_id in attachments:
self.db.quarmail2attachment(str(quarmail_id), str(attachment_id))
logging.info(whoami(self) +
"Attachment("+str(attachment_id)+")@QuarMail("+str(quarmail_id)+") imported"
"Attachment("+str(attachment_id)+")@QuarMail("+
str(quarmail_id)+") imported"
)
# link message with uris
if(len(uris) > 0):
@ -270,7 +276,9 @@ class Gulag:
imap_mb = None
try:
imap_mb = IMAPmailbox(mailbox)
qm_db['rfc822_message'] = imap_mb.get_message(qm_db['imap_uid']).decode("utf-8")
qm_db['rfc822_message'] = imap_mb.get_message(
qm_db['imap_uid']
).decode("utf-8")
return qm_db
except IMAPmailboxException as e:
logging.warning(whoami(self) + e.message)
@ -468,4 +476,3 @@ class Gulag:
imap_mb.append_message(msg)
except IMAPmailboxException as e:
raise GulagException(whoami(self) + e.message) from e

View File

@ -156,6 +156,24 @@ paths:
description: bad input parameter
500:
description: server error
delete:
summary: deletes a quarantined email
operationId: delete_quarmail
produces:
- application/json
parameters:
- in: path
name: quarmail_id
description: unique id of quarantined email
required: true
type: integer
responses:
200:
description: quarantined email deleted
400:
description: bad input parameter
500:
description: server error
/quarmails/{quarmail_id}/attachments:
get: