added a check in the make_reply function to ensure that mails have a body
All checks were successful
/ test (pull_request) Successful in 2m36s
/ test (push) Successful in 2m42s
/ deploy (push) Successful in 5m29s

This commit is contained in:
bton 2024-12-04 22:57:12 +01:00 committed by jedi
parent 89707113bb
commit 9ac1e9706f
18 changed files with 9529 additions and 21 deletions

View file

@ -0,0 +1,26 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: multipart/alternative; boundary="abc"
--abc
Content-Type: text/plain; charset=utf-8
test1
--abc
Content-Type: image/jpeg; name="test.jpg"
Content-Disposition: inline; filename="test.jpg"
Content-Transfer-Encoding: base64
Content-ID: <1>
X-Attachment-Id: 1
dGVzdGltYWdl
--abc
Content-Type: text/plain; charset=utf-8
test2
--abc--

View file

@ -0,0 +1,5 @@
Subject: test
From: <test1@test>
To: test2@test
Message-ID: <1@test>

View file

@ -0,0 +1,8 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
hello =C3=A4=C3=B6=C3=BC

View file

@ -0,0 +1,6 @@
Subject: test
From: test3@test
To: test4@localhost
Message-ID: <1@test>
test

View file

@ -0,0 +1,6 @@
Subject: =?UTF-8?Q?suche_M=C3=BCtze?=
From: test3@test
To: test4@test
Message-ID: <1@test>
Text mit Quoted-Printable-Kodierung: =?utf-8?Q?=C3=A4=C3=B6=C3=BC=C3=9F?=

View file

@ -0,0 +1,7 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: text/html; charset=iso-8859-1
hello äöü

View file

@ -0,0 +1,21 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: multipart/mixed; boundary="abc"
--abc
Content-Type: text/plain; charset=utf-8
test1
--abc
Content-Type: image/jpeg; name="test.jpg"
Content-Disposition: attachment; filename="test.jpg"
Content-Transfer-Encoding: base64
Content-ID: <1>
X-Attachment-Id: 1
dGVzdGltYWdl
--abc--

View file

@ -0,0 +1,11 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: text/html; charset=utf-8
<div>
<div>
<p>test</p>
</div>
</div>

View file

@ -0,0 +1,6 @@
Subject: test =?utf-8?Q?=C3=A4?=
From: test3@test
To: test4@test
Message-ID: <1@test>
Text mit Quoted-Printable-Kodierung: =?utf-8?Q?=C3=A4=C3=B6=C3=BC=C3=9F?=

View file

@ -0,0 +1,6 @@
Subject: =?utf-8?B?dGVzdA==?=
From: test3@test
To: test4@test
Message-ID: <1@test>
Text mit Base64-Kodierung: =?utf-8?B?w6TDtsO8w58=?=

View file

@ -0,0 +1,6 @@
Subject: test
From: test1@test
To: test_event@localhost
Message-ID: <1@test>
test

View file

@ -0,0 +1,5 @@
From: noreply@test
To: test2@test
Message-ID: <1@test>
test

View file

@ -0,0 +1,7 @@
Subject: test
From: test1@test
To: test2@test
Message-ID: <1@test>
Content-Type: text/html; charset=utf-8
thank you =?utf-8?Q?=F0=9F=98=8A?=

View file

@ -93,11 +93,11 @@ def make_reply(reply_email, references=None, event=None):
reply_email.save()
if references:
reply["References"] = " ".join(references)
reply.set_content(reply_email.body)
return reply
if reply_email.body != "":
reply.set_content(reply_email.body)
return reply
else:
raise SpecialMailException("mail content emty")
async def send_smtp(message):
await aiosmtplib.send(message, hostname="127.0.0.1", port=25, use_tls=False, start_tls=False)
@ -299,10 +299,10 @@ class LMTPHandler:
systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received',
reference=email.id)
log.info(f"Created system event {systemevent.id}")
channel_layer = get_channel_layer()
await channel_layer.group_send(
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
"message": "email received"})
#channel_layer = get_channel_layer()
#await channel_layer.group_send(
# 'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
# "message": "email received"})
log.info(f"Sent message to frontend")
if new and reply:
log.info('Sending message to %s' % reply['To'])

0
core/testdata.py Normal file
View file

View file

@ -102,12 +102,6 @@ def manual_ticket(request, event_slug):
subject=request.data['name'],
body=request.data['body'],
)
systemevent = SystemEvent.objects.create(type='email received', reference=email.id)
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
"message": "email received"}
)
return Response(IssueSerializer(issue).data, status=status.HTTP_201_CREATED)
@ -133,12 +127,6 @@ def add_comment(request, pk):
issue_thread=issue,
comment=request.data['comment'],
)
systemevent = SystemEvent.objects.create(type='comment added', reference=comment.id)
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
"message": "comment added"}
)
return Response(CommentSerializer(comment).data, status=status.HTTP_201_CREATED)

View file

@ -7,6 +7,7 @@ services:
environment:
- HTTP_HOST=core
- DB_FILE=dev.db
- DEBUG_MODE_ACTIVE=true
volumes:
- ../../core:/code
- ../testdata.py:/code/testdata.py

9399
web/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff