Skip to content

Commit 13cf823

Browse files
committed
feat: store body and attachment in db as well
1 parent da0dff3 commit 13cf823

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mftp/mail.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def format_notice(notices, session):
7878

7979
try:
8080
body = parseBody(session, year, id_)
81+
notice['Body'] = body
8182
except Exception as e:
8283
logging.error(f" Failed to parse mail body ~ {str(e)}")
8384
break
@@ -115,6 +116,8 @@ def format_notice(notices, session):
115116
break
116117

117118
if len(attachment) != 0:
119+
notice['Attachment'] = attachment
120+
118121
file = MIMEBase('application', 'octet-stream')
119122
file.set_payload(attachment)
120123
encoders.encode_base64(file)

mftp/ntfy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def format_notice(notices, session):
5252

5353
try:
5454
data = parseBody(notice, session, year, id_)
55+
notice['Body'] = data
5556
body, links = parseLinks(data)
5657
body += '''
5758
--------------
@@ -90,6 +91,8 @@ def format_notice(notices, session):
9091
break
9192

9293
if len(attachment) != 0:
94+
notice['Attachment'] = attachment
95+
9396
file_name = notification['Attachment']
9497
if save_file(file_name, attachment):
9598
notification['Attachment'] = file_name
@@ -104,6 +107,7 @@ def format_notice(notices, session):
104107

105108

106109
def send(notifications, notice_db):
110+
print('[SENDING NOTIFICATIONS]', flush=True)
107111

108112
for notif in notifications:
109113
notification = notif.get('formatted_notice')
@@ -116,9 +120,6 @@ def send(notifications, notice_db):
116120
if len(latest_successful_subscribers) != 0:
117121
ntfy_topics = [subscirber for subscirber in ntfy_topics if subscirber not in latest_successful_subscribers]
118122

119-
if ntfy_topics:
120-
print('[SENDING NOTIFICATIONS]', flush=True)
121-
122123
for ntfy_topic in ntfy_topics:
123124
try:
124125
query_params = f"message={quote(notification['Body'])}"

0 commit comments

Comments
 (0)