mirror of
https://github.com/chillout2k/gulag.git
synced 2025-12-13 16:00:18 +00:00
Swagger file update
This commit is contained in:
parent
76acc94391
commit
937b805779
27
app/Gulag.py
27
app/Gulag.py
@ -1,4 +1,4 @@
|
|||||||
import json,sys,os,logging,re,magic
|
import json, sys,os,logging,re,magic
|
||||||
import email,email.header,email.message
|
import email,email.header,email.message
|
||||||
from GulagDB import GulagDB,GulagDBException
|
from GulagDB import GulagDB,GulagDBException
|
||||||
from GulagMailbox import IMAPmailbox,IMAPmailboxException
|
from GulagMailbox import IMAPmailbox,IMAPmailboxException
|
||||||
@ -90,7 +90,8 @@ class Gulag:
|
|||||||
r5321_from = r5321_from.replace(">","")
|
r5321_from = r5321_from.replace(">","")
|
||||||
r5321_rcpts = None
|
r5321_rcpts = None
|
||||||
try:
|
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:
|
except:
|
||||||
logging.warning(whoami(self) +
|
logging.warning(whoami(self) +
|
||||||
"Failed to extract envelope recipients! Skipping mail"
|
"Failed to extract envelope recipients! Skipping mail"
|
||||||
@ -130,10 +131,12 @@ class Gulag:
|
|||||||
# über die mailbox_id sowie die imap_uid mehrfach referenziert.
|
# über die mailbox_id sowie die imap_uid mehrfach referenziert.
|
||||||
for r5321_rcpt in r5321_rcpts.split(","):
|
for r5321_rcpt in r5321_rcpts.split(","):
|
||||||
quarmail_id = self.db.add_quarmail({
|
quarmail_id = self.db.add_quarmail({
|
||||||
'mx_queue_id': mx_queue_id, 'env_from': r5321_from, 'env_rcpt': r5321_rcpt,
|
'mx_queue_id': mx_queue_id, 'env_from': r5321_from,
|
||||||
'hdr_cf': x_spam_status, 'hdr_from': r5322_from, 'hdr_subject': subject,
|
'env_rcpt': r5321_rcpt, 'hdr_cf': x_spam_status,
|
||||||
'hdr_msgid': msg_id, 'hdr_date': date, 'cf_meta': 'cf_meta',
|
'hdr_from': r5322_from, 'hdr_subject': subject,'hdr_msgid': msg_id,
|
||||||
'mailbox_id': 'quarantine@zwackl.de', 'imap_uid': uid, 'msg_size': msg_size
|
'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))
|
logging.info(whoami(self) + "QuarMail (%s) imported" % (quarmail_id))
|
||||||
quarmail_ids.append(quarmail_id)
|
quarmail_ids.append(quarmail_id)
|
||||||
@ -167,7 +170,9 @@ class Gulag:
|
|||||||
ctype = part.get_content_type()
|
ctype = part.get_content_type()
|
||||||
if(ctype == 'text/plain' or ctype == 'text/html'):
|
if(ctype == 'text/plain' or ctype == 'text/html'):
|
||||||
curis = {}
|
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):
|
if(len(curis) > 0):
|
||||||
logging.info(whoami(self) + "CURIS: " + str(curis))
|
logging.info(whoami(self) + "CURIS: " + str(curis))
|
||||||
uris = {**uris, **curis}
|
uris = {**uris, **curis}
|
||||||
@ -178,7 +183,8 @@ class Gulag:
|
|||||||
for attachment_id in attachments:
|
for attachment_id in attachments:
|
||||||
self.db.quarmail2attachment(str(quarmail_id), str(attachment_id))
|
self.db.quarmail2attachment(str(quarmail_id), str(attachment_id))
|
||||||
logging.info(whoami(self) +
|
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
|
# link message with uris
|
||||||
if(len(uris) > 0):
|
if(len(uris) > 0):
|
||||||
@ -270,7 +276,9 @@ class Gulag:
|
|||||||
imap_mb = None
|
imap_mb = None
|
||||||
try:
|
try:
|
||||||
imap_mb = IMAPmailbox(mailbox)
|
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
|
return qm_db
|
||||||
except IMAPmailboxException as e:
|
except IMAPmailboxException as e:
|
||||||
logging.warning(whoami(self) + e.message)
|
logging.warning(whoami(self) + e.message)
|
||||||
@ -468,4 +476,3 @@ class Gulag:
|
|||||||
imap_mb.append_message(msg)
|
imap_mb.append_message(msg)
|
||||||
except IMAPmailboxException as e:
|
except IMAPmailboxException as e:
|
||||||
raise GulagException(whoami(self) + e.message) from e
|
raise GulagException(whoami(self) + e.message) from e
|
||||||
|
|
||||||
|
|||||||
@ -156,6 +156,24 @@ paths:
|
|||||||
description: bad input parameter
|
description: bad input parameter
|
||||||
500:
|
500:
|
||||||
description: server error
|
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:
|
/quarmails/{quarmail_id}/attachments:
|
||||||
get:
|
get:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user