release_2024-11-13 #88
4 changed files with 40 additions and 2 deletions
36
core/mail/migrations/0006_email_raw_file.py
Normal file
36
core/mail/migrations/0006_email_raw_file.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# Generated by Django 4.2.7 on 2024-11-08 20:37
|
||||||
|
from django.core.files.base import ContentFile
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mail', '0005_alter_eventaddress_event'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def move_raw_mails_to_file(apps, schema_editor):
|
||||||
|
Email = apps.get_model('mail', 'Email')
|
||||||
|
for email in Email.objects.all():
|
||||||
|
raw_content = email.raw
|
||||||
|
email.raw_file = ContentFile(raw_content)
|
||||||
|
email.raw = None
|
||||||
|
email.save()
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='email',
|
||||||
|
name='raw_file',
|
||||||
|
field=models.FileField(null=True, upload_to='raw_mail/'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(move_raw_mails_to_file),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='email',
|
||||||
|
name='raw',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='email',
|
||||||
|
name='raw_file',
|
||||||
|
field=models.FileField(upload_to='raw_mail/'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -18,7 +18,7 @@ class Email(SoftDeleteModel):
|
||||||
recipient = models.CharField(max_length=255)
|
recipient = models.CharField(max_length=255)
|
||||||
reference = models.CharField(max_length=255, null=True, unique=True)
|
reference = models.CharField(max_length=255, null=True, unique=True)
|
||||||
in_reply_to = models.CharField(max_length=255, null=True)
|
in_reply_to = models.CharField(max_length=255, null=True)
|
||||||
raw = models.TextField()
|
raw_file = models.FileField(upload_to='raw_mail/')
|
||||||
issue_thread = models.ForeignKey(IssueThread, models.SET_NULL, null=True, related_name='emails')
|
issue_thread = models.ForeignKey(IssueThread, models.SET_NULL, null=True, related_name='emails')
|
||||||
event = models.ForeignKey(Event, models.SET_NULL, null=True)
|
event = models.ForeignKey(Event, models.SET_NULL, null=True)
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ def receive_email(envelope, log=None):
|
||||||
|
|
||||||
email = Email.objects.create(
|
email = Email.objects.create(
|
||||||
sender=sender, recipient=recipient, body=body, subject=subject, reference=header_message_id,
|
sender=sender, recipient=recipient, body=body, subject=subject, reference=header_message_id,
|
||||||
in_reply_to=header_in_reply_to, raw=envelope.content, event=target_event,
|
in_reply_to=header_in_reply_to, raw_file=ContentFile(envelope.content), event=target_event,
|
||||||
issue_thread=active_issue_thread)
|
issue_thread=active_issue_thread)
|
||||||
for attachment in attachments:
|
for attachment in attachments:
|
||||||
email.attachments.add(attachment)
|
email.attachments.add(attachment)
|
||||||
|
|
|
@ -73,3 +73,5 @@ watchfiles==0.21.0
|
||||||
websockets==12.0
|
websockets==12.0
|
||||||
yarl==1.9.4
|
yarl==1.9.4
|
||||||
zope.interface==6.1
|
zope.interface==6.1
|
||||||
|
django-prometheus==2.3.1
|
||||||
|
prometheus_client==0.21.0
|
||||||
|
|
Loading…
Reference in a new issue