mirror of
https://github.com/chatmail/relay.git
synced 2026-05-22 22:08:03 +00:00
refactor into a handle_dovecot_request function
This commit is contained in:
@@ -22,9 +22,16 @@ def handle_dovecot_protocol(rfile, wfile, tokens, requests_session, config: Conf
|
||||
if not msg:
|
||||
break
|
||||
|
||||
res = handle_dovecot_request(msg, tokens, requests_session, config)
|
||||
if res:
|
||||
wfile.write(res.encode("ascii"))
|
||||
wfile.flush()
|
||||
|
||||
|
||||
def handle_dovecot_request(msg, tokens, requests_session, config: Config):
|
||||
short_command = msg[0]
|
||||
if short_command == "L":
|
||||
wfile.write(b"N\n")
|
||||
return b"N\n"
|
||||
elif short_command == "S":
|
||||
# See header of
|
||||
# <https://github.com/dovecot/core/blob/5e7965632395793d9355eb906b173bf28d2a10ca/src/lib-storage/mailbox-attribute.h>
|
||||
@@ -67,9 +74,7 @@ def handle_dovecot_protocol(rfile, wfile, tokens, requests_session, config: Conf
|
||||
elif short_command == "C":
|
||||
# Commit transaction.
|
||||
transaction_id = msg[1:].split("\t")[0]
|
||||
wfile.write(transactions.pop(transaction_id, b"N\n"))
|
||||
|
||||
wfile.flush()
|
||||
return transactions.pop(transaction_id, b"N\n")
|
||||
|
||||
|
||||
class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
||||
|
||||
Reference in New Issue
Block a user