From b65f255cf84a757933b0270867e263c86c604df6 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 9 Nov 2024 01:00:53 +0100 Subject: [PATCH] train spam on state change to 'closed_spam' --- core/mail/migrations/0006_email_raw_file.py | 2 +- core/tickets/models.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/mail/migrations/0006_email_raw_file.py b/core/mail/migrations/0006_email_raw_file.py index 1288bcf..68addbf 100644 --- a/core/mail/migrations/0006_email_raw_file.py +++ b/core/mail/migrations/0006_email_raw_file.py @@ -13,8 +13,8 @@ class Migration(migrations.Migration): Email = apps.get_model('mail', 'Email') for email in Email.objects.all(): raw_content = email.raw + print("raw_content size:", len(raw_content)) email.raw_file = ContentFile(raw_content) - email.raw = None email.save() operations = [ diff --git a/core/tickets/models.py b/core/tickets/models.py index db427fe..aff5d6c 100644 --- a/core/tickets/models.py +++ b/core/tickets/models.py @@ -60,6 +60,8 @@ class IssueThread(SoftDeleteModel): if self.state == value: return self.state_changes.create(state=value) + if value == 'closed_spam' and self.emails.exists(): + self.emails.first().train_spam() @property def assigned_to(self):