add functions to train mails as spam/ham
This commit is contained in:
parent
e9c8f1049e
commit
737aa69024
4 changed files with 26 additions and 4 deletions
|
@ -3,7 +3,7 @@ import random
|
|||
from django.db import models
|
||||
from django_softdelete.models import SoftDeleteModel
|
||||
|
||||
from core.settings import MAIL_DOMAIN
|
||||
from core.settings import MAIL_DOMAIN, ACTIVE_SPAM_TRAINING
|
||||
from files.models import AbstractFile
|
||||
from inventory.models import Event
|
||||
from tickets.models import IssueThread
|
||||
|
@ -28,6 +28,18 @@ class Email(SoftDeleteModel):
|
|||
self.reference = f'<{random.randint(0, 1000000000):09}@{MAIL_DOMAIN}>'
|
||||
self.save()
|
||||
|
||||
def train_spam(self):
|
||||
if ACTIVE_SPAM_TRAINING:
|
||||
import subprocess
|
||||
path = self.raw_file.path
|
||||
subprocess.run(["rspamc", "learn_spam", path])
|
||||
|
||||
def train_ham(self):
|
||||
if ACTIVE_SPAM_TRAINING:
|
||||
import subprocess
|
||||
path = self.raw_file.path
|
||||
subprocess.run(["rspamc", "learn_ham", path])
|
||||
|
||||
|
||||
class EventAddress(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue