Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from django.template.base import TemplateEncodingError
from django.template import engines, TemplateSyntaxError
from .base import (
EMAIL_VALID_CATEGORIES,
Email,
EmailServiceBase,
EmailServiceException,
PrefetchedEmail,
)
from ...models import MailTemplate, Ticket
django_template_engine = engines["django"]
html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True
class TemplateNeedProofError(Exception):
"""
TemplateNeedProofError
"""
def __init__(self, message):
super(TemplateNeedProofError, self).__init__(message)
class DefaultMailerService(EmailServiceBase):
"""
Handling basic mailer interactions. Store emails in a naive sqlite DB.
from ...models import (
AbusePermission,
Defendant,
Report,
ReportItem,
Service,
Tag,
Ticket,
)
from ...services.search import SearchService, SearchServiceException
from ...services.storage import StorageService, StorageServiceException
from ...parsers import Parser
from ...tasks import enqueue
html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True
def get_reports(**kwargs):
""" Main endpoint, get all reports from db and eventually contains
filters (json format) in query like sortBy, where ...
"""
# Parse filters from request
filters = {}
if kwargs.get("filters"):
try:
filters = json.loads(unquote(unquote(kwargs["filters"])))
except (ValueError, SyntaxError, TypeError) as ex:
raise BadRequest(str(ex.message))
try:
limit = int(filters["paginate"]["resultsPerPage"])
email_queue = Queue(
connection=Redis(**settings.REDIS),
**settings.QUEUE['email']
)
kpi_queue = Queue(
connection=Redis(**settings.REDIS),
**settings.QUEUE['kpi']
)
scheduler = Scheduler(connection=Redis(**settings.REDIS))
redis = Redis(**settings.REDIS)
html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True
DNS_ERROR = {
'-2': 'NXDOMAIN'
}
class CryptoException(Exception):
"""
CryptoException
"""
def __init__(self, message):
super(CryptoException, self).__init__(message)
class Crypto(object):
from datetime import datetime
from HTMLParser import HTMLParseError
import html2text
from django.db.models import ObjectDoesNotExist
from django.template import TemplateSyntaxError, engines
from django.template.base import TemplateEncodingError
from ..models import MailTemplate
from ..services.email.base import Email
html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True
class EmailThreadTemplateNotFound(Exception):
"""
EmailThreadTemplateNotFound
"""
def __init__(self, message):
super(EmailThreadTemplateNotFound, self).__init__(message)
class EmailThreadTemplateSyntaxError(Exception):
"""
EmailThreadTemplateSyntaxError
"""