aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xapp.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/app.py b/app.py
index 4266858..289ff16 100755
--- a/app.py
+++ b/app.py
@@ -146,7 +146,7 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
# EMAIL STUFF IS TO BE ADDED HERE
# Why not in a separate email_stuff() function?
# Because lazy
- mbox = mailbox.Maildir("/home/qbox/Mail/Inbox")
+ mbox = mailbox.Maildir(config.MAILDIR_LOCATION)
for msg_id, msg in mbox.items():
if msg.get_subdir() != "new":
continue
@@ -178,7 +178,11 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
newmsg["In-Reply-To"] = msg["Message-ID"]
elif "Message-Id" in msg.keys():
newmsg["In-Reply-To"] = msg["Message-Id"]
- newmsg["Message-Id"] = "<qbox-system-%s@%s>" % (ts, config.MAIL_HOST)
+ newmsg["Message-Id"] = "<%s-system-%s@%s>" % (
+ config.MAIL_PREFIX,
+ ts,
+ config.MAIL_HOST,
+ )
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
p.communicate(newmsg.as_bytes())
continue
@@ -191,7 +195,7 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
reply_identifier = parsed_address[1] # Should be ts
for question in reversed(db):
assert type(question["ts"]) is str
- if reply_identifier == "qbox-" + question["ts"]:
+ if reply_identifier == config.MAIL_PREFIX + "-" + question["ts"]:
break
else:
ts = str(time.time())
@@ -208,7 +212,11 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
newmsg["In-Reply-To"] = msg["Message-ID"]
elif "Message-Id" in msg.keys():
newmsg["In-Reply-To"] = msg["Message-Id"]
- newmsg["Message-Id"] = "<qbox-system-%s@%s>" % (ts, config.MAIL_HOST)
+ newmsg["Message-Id"] = "<%s-system-%s@%s>" % (
+ config.MAIL_PREFIX,
+ ts,
+ config.MAIL_HOST,
+ )
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
p.communicate(newmsg.as_bytes())
continue
@@ -235,7 +243,8 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
newmsg["In-Reply-To"] = msg["Message-ID"]
elif "Message-Id" in msg.keys():
newmsg["In-Reply-To"] = msg["Message-Id"]
- newmsg["Message-Id"] = "<qbox-system-%s@%s>" % (
+ newmsg["Message-Id"] = "<%s-system-%s@%s>" % (
+ config.MAIL_PREFIX,
ts,
config.MAIL_HOST,
)
@@ -270,7 +279,11 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
newmsg["In-Reply-To"] = msg["Message-ID"]
elif "Message-Id" in msg.keys():
newmsg["In-Reply-To"] = msg["Message-Id"]
- newmsg["Message-Id"] = "<qbox-system-%s@%s>" % (ts, config.MAIL_HOST)
+ newmsg["Message-Id"] = "<%s-system-%s@%s>" % (
+ config.MAIL_PREFIX,
+ ts,
+ config.MAIL_HOST,
+ )
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
p.communicate(newmsg.as_bytes())
return render_template(
@@ -294,7 +307,11 @@ def qboard(user: str) -> Union[Response, werkzeugResponse, str, tuple[str, int]]
newmsg["From"] = config.MAIL_PREFIX + "@" + config.MAIL_HOST
newmsg["To"] = config.MAPPING[user][0]
newmsg["Subject"] = "Question Box Message"
- newmsg["Message-Id"] = "<qbox-%s@%s>" % (ts, config.MAIL_HOST)
+ newmsg["Message-Id"] = "<%s-%s@%s>" % (
+ config.MAIL_PREFIX,
+ ts,
+ config.MAIL_HOST,
+ )
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
p.communicate(newmsg.as_bytes())
else: