<commit_before># -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

import hashlib
from datetime import timedelta
from superdesk.utc import utcnow
from eve.utils import config
from bson.json_util import dumps
from flask.ext.mail import Message
from superdesk.celery_app import celery
from flask import current_app as app, render_template, render_template_string
from superdesk import get_resource_service


EMAIL_TIMESTAMP_RESOURCE = 'email_timestamps'


@celery.task(bind=True, max_retries=3, soft_time_limit=10)
def send_email(self, subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    return app.mail.send(msg)


def send_activate_account_email(doc):
    user = get_resource_service('users').find_one(req=None, _id=doc['user'])
    activate_ttl = app.config['ACTIVATE_ACCOUNT_TOKEN_TIME_TO_LIVE']
    app_name = app.config['APPLICATION_NAME']
    admins = app.config['ADMINS']
    client_url = app.config['CLIENT_URL']
    url = '{}/#/reset-password?token={}'.format(client_url, doc['token'])
    hours = activate_ttl * 24
    subject = render_template("account_created_subject.txt", app_name=app_name)
    text_body = render_template("account_created.txt", app_name=app_name, user=user,
                                instance_url=client_url, expires=hours, url=url)<commit_msg>SDPA-456 : Increase soft time limit for emails<commit_after># -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

import hashlib
from datetime import timedelta
from superdesk.utc import utcnow
from eve.utils import config
from bson.json_util import dumps
from flask.ext.mail import Message
from superdesk.celery_app import celery
from flask import current_app as app, render_template, render_template_string
from superdesk import get_resource_service


EMAIL_TIMESTAMP_RESOURCE = 'email_timestamps'


@celery.task(bind=True, max_retries=3, soft_time_limit=100)
def send_email(self, subject, sender, recipients, text_body, html_body):
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    msg.html = html_body
    return app.mail.send(msg)


def send_activate_account_email(doc):
    user = get_resource_service('users').find_one(req=None, _id=doc['user'])
    activate_ttl = app.config['ACTIVATE_ACCOUNT_TOKEN_TIME_TO_LIVE']
    app_name = app.config['APPLICATION_NAME']
    admins = app.config['ADMINS']
    client_url = app.config['CLIENT_URL']
    url = '{}/#/reset-password?token={}'.format(client_url, doc['token'])
    hours = activate_ttl * 24
    subject = render_template("account_created_subject.txt", app_name=app_name)
    text_body = render_template("account_created.txt", app_name=app_name, user=user,
                                instance_url=client_url, expires=hours, url=url)
{'fraction_non_alphanumeric': 0.100418410041841, 'fraction_numerical': 0.009563658099222952, 'mean_word_length': 4.923893805309734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7193867', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1041, 'n_words': 259}