Skip to content

Commit 71f7ea5

Browse files
authored
v.1.8.2 update
1 parent 7b3a780 commit 71f7ea5

File tree

14 files changed

+390
-284
lines changed

14 files changed

+390
-284
lines changed

CHANGES.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ Unreleased VER.
1010
- MS Exchange multiple mail_to processing
1111
- [fix of non-dockerizeed deploy issue](https://github.com/drlight17/mta-log-parser/issues/10)
1212
- provide variables in .env for user defined parser regexps override
13-
- don't update rows in table while parsing is running (cause multiple recipients with wrong status) - block page update while parsing is running?
14-
- BUG: email details modal -> subject - sometimes colored as status:
15-
`Invitation to Submit Abstract for 20-Minute Oral Presentation`
13+
- parse log file from the new lines since last parsing
14+
15+
16+
VER. 1.8.2
17+
- ~~some GUI styling fixes~~
18+
- ~~don't update rows in table while parsing is running (cause multiple recipients with wrong status) - block page update while parsing is running by env variable~~
19+
- ~~BUG: mailto splitting process issue~~
1620

1721
VER. 1.8.1
1822
- ~~BUG: exim multiple mail_to parsing fix~~

example.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ PORT=8487
4141
# make date time format (default is "HH:mm:ss, DD.MM.YYYY") to use in GUI for emails list timestamps and date picker according to moment.js templates (https://momentjs.com/)
4242
#DATETIME_FORMAT='HH:mm:ss, DD.MM.YYYY'
4343

44-
# convert related logs timestamp according to the DATETIME_FORMAT. High CPU demanding! false by default
44+
# convert related logs timestamp according to the DATETIME_FORMAT. High CPU demanding! (false by default)
4545
#MAIL_LOG_TIMESTAMP_CONVERT=false
4646

4747
# set MTA which logs you waunt to parse; available values are exim, postfix (default), sendmail and exchange
@@ -53,6 +53,9 @@ PORT=8487
5353
# set email addresses to exclude from top recipients stats permanently (comma separated)
5454
#EXCLUDE_FROM_TOP_RECIPIENTS='[email protected],[email protected]'
5555

56+
# block GUI refresh while parser worker is running (true by default)
57+
GUI_REFRESH_BLOCK=true
58+
5659
# set startup command
5760
# dev to run in python developer mode
5861
# prod to run in production mode (default)

mlp/main.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import base64
3131
import quopri
3232
import json
33+
import os
3334

3435
from datetime import datetime, timedelta, timezone
3536
from quart import jsonify
@@ -43,8 +44,9 @@
4344

4445
# !!! change version upon update !!!
4546
global VERSION
46-
VERSION ="1.8.1"
47+
VERSION ="1.8.2"
4748

49+
lockfile = "processing.lock"
4850
# postf_match += r'([A-F0-9]{11})\:[ \t]+?(.*)'
4951
#postf_match = r'([A-Za-z]+[ \t]+[0-9]+[ \t]+[0-9]+\:[0-9]+:[0-9]+).*'
5052
#postf_match += r'.*\:[ \t]([A-Z0-9]{1,15})\:[ \t]+?(.*)'
@@ -101,7 +103,6 @@ class OnConflict(Enum):
101103
EXCEPT = "except"
102104
UPDATE = "update"
103105

104-
105106
async def save_obj(table, data, primary=None, onconflict: OnConflict = OnConflict.EXCEPT):
106107
r, conn, _ = await get_rethink()
107108
_data = dict(data)
@@ -265,12 +266,14 @@ async def import_log(logfile: str) -> Dict[str, PostfixMessage]:
265266
if messages[qid]['status'].get('code') is not None:
266267
# check if there are already recipients in message and there are recipients parsed
267268
#print("Looking for ",checking_mailto," in message \"",msg, "\" related to qid ", qid)
268-
if checking_mailto != '':
269+
if checking_mailto != '' and checking_mailto is not None:
269270
#if qid == '1sBTAv-0018OM-4k':
270271
# print(checking_mailto)
271272
# print(msg)
272273
# 27.05.2024 need tests added 'or' below to compare full email or only local part
273-
if checking_mailto in msg or checking_mailto.split('@')[0] in msg:
274+
if '@' in checking_mailto:
275+
checking_mailto = checking_mailto.split('@')[0]
276+
if checking_mailto in msg:
274277
same_qid = qid
275278
counter += 1
276279
# don't add email duplicates
@@ -356,10 +359,16 @@ def decodev2(a):
356359
# return _sm
357360

358361
async def main():
362+
359363
r, conn, r_q = await get_rethink()
360364
r_q: rethinkdb.query
361-
"""housekeeping from old logs"""
362365

366+
if settings.gui_refresh_block:
367+
log.info('Blocking GUI updates while processing')
368+
global lockfile
369+
t = open(lockfile, "w")
370+
371+
"""housekeeping from old logs"""
363372
housekeeping_days = settings.housekeeping_days
364373
if housekeeping_days != '':
365374
log.info('Start housekeeping')
@@ -412,8 +421,8 @@ async def main():
412421
else:
413422
mfrom_dom = mfrom
414423

415-
if mto != '':
416-
if '@' in mfrom:
424+
if mto != '' and mto is not None:
425+
if '@' in mto:
417426
mto_dom = mto.split('@')[1]
418427
else:
419428
mto_dom = ''
@@ -438,6 +447,8 @@ async def main():
438447

439448
log.info('Firing off asyncio.gather(save_list)...')
440449
await asyncio.gather(*save_list)
441-
450+
if settings.gui_refresh_block:
451+
log.info('Unblocking GUI updates')
452+
os.remove(lockfile)
442453
log.info('Finished!')
443454

mlp/parser.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,15 @@ async def parse_line(mline) -> dict:
145145
if _to is not None:
146146
if settings.mta == 'exchange':
147147
lm['mail_to'] = _to.group(1)[:-1]
148-
if settings.mta == 'postfix':
148+
'''if settings.mta == 'postfix':
149149
if _to.group(2) is not None:
150150
aliases = {_to.group(1):_to.group(2)}
151-
#aliases.append(_to.group(2))
152151
lm['mail_to_alias'] = aliases
153152
if _to.group(1) is not None:
154153
lm['mail_to'] = _to.group(1)
155-
#if _to.group(2) is not None:
156-
# lm['mail_to'] +=' ('+_to.group(2)+')'
157154
else:
158-
lm['mail_to'] = _to.group(3)
159-
if settings.mta == 'exim':
155+
lm['mail_to'] = _to.group(3)'''
156+
if settings.mta == 'exim' or settings.mta == 'postfix':
160157
'''if _to.group(2) is not None:
161158
lm['mail_to'] = _to.group(2)
162159
else:

mlp/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
# add mail_log_timestamp_convert var from env
7777
mail_log_timestamp_convert = env_bool('MAIL_LOG_TIMESTAMP_CONVERT', False)
7878

79+
# add gui_refresh_block var from env
80+
gui_refresh_block = env_bool('GUI_REFRESH_BLOCK', True)
81+
7982
# add mta var from env
8083
mta = env('MTA', '')
8184

mlp/static/css/style.css

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@
3535
.stats_refresh:hover, .trash.alternate.icon:hover {
3636
opacity: 1!important;
3737
}
38-
38+
/**disabled style override*/
39+
.disabled {
40+
opacity: 0.7!important;
41+
pointer-events: none!important;
42+
}
43+
/*.ui.inverted.table {
44+
background: #2b2b2b !important;
45+
}*/
3946
.stats_refresh {
4047
transition: all 0.15s ease-in-out;
4148
opacity: .7!important;
@@ -97,6 +104,21 @@
97104
justify-content: flex-end!important;
98105
}
99106

107+
@media only screen and (min-width: 768px) {
108+
#overall_pie_title {
109+
max-width: 13vw;
110+
}
111+
}
112+
113+
/*prevent long press text selection*/
114+
#filtered_top_recipients, #filtered_top_senders,#charts-wrapper span {
115+
-webkit-touch-callout: none;
116+
-webkit-user-select: none;
117+
-moz-user-select: none;
118+
-ms-user-select: none;
119+
user-select: none;
120+
}
121+
100122
/*.hidable.hide {
101123
display:none!important;
102124
}*/
@@ -406,7 +428,7 @@ summary {
406428
background-color: #e1dcdc!important;
407429
}*/
408430
/*for sticky pager*/
409-
.ui.buttons {
431+
#navi {
410432
z-index: 5;
411433
position: sticky;
412434
bottom: 0;
@@ -599,7 +621,7 @@ button:not(.navi), #footer {
599621
/*white-space: break-spaces;*/
600622
overflow: hidden;
601623
text-overflow: ellipsis;
602-
max-width: 400px;
624+
max-width: 87vw;
603625
}
604626
/*
605627
#email-metadata td:hover {
@@ -784,6 +806,7 @@ div.multiple_with_aliases::marker, td.mail_to > span.multiple::marker {
784806
opacity: .5!important;
785807
position: sticky;
786808
top:50%;
809+
background: radial-gradient(circle, rgb(0 0 0) 0%, rgb(255 255 255 / 0%) 80%);
787810
}
788811

789812
.next_email:hover i, .next_email:focus i, .prev_email:hover i, .prev_email:focus i {
@@ -906,6 +929,10 @@ div.ui.menu.item.contextMenu.animate {
906929
line-height: 24px;
907930
font-family: sans-serif;
908931
padding: 4px 10px;
932+
max-width: 200px;
933+
text-align: left;
934+
/*overflow: hidden;*/
935+
text-overflow: ellipsis;
909936
}
910937

911938
.menu-item:hover {

0 commit comments

Comments
 (0)