<commit_before>const Config                        = use('config');
const Property                      = use('core/property');

const NotificationEmailRepository   = require('./repository');
const EMAIL_STATUS                  = require('./enums/statuses');
const EMAIL_TYPE                    = require('./enums/types');


const NotificationEmailDefinition = {

    name: 'NotificationsEmail',

    repository: NotificationEmailRepository,

    properties: {
        id                      : Property.id(),
        message_id              : Property.string().max(255),
        provider_name           : Property.string(),
        accounts_senders_id     : Property.id(),
        sender_email            : Property.string().max(255),
        subject                 : Property.string().max(255),
        body                    : Property.string().max(64500),
        recipient_email_to      : Property.object(),
        recipient_email_cc      : Property.object(),
        recipient_email_bcc     : Property.object(),
        accounts_recipients_id  : Property.id(),
        account_recipients_id   : Property.id(),
        status                  : Property.enum(Object.keys(EMAIL_STATUS)),
        type                    : Property.enum(Object.keys(EMAIL_TYPE))
    },

    factory: {
        EMAIL_STATUS,
        EMAIL_TYPE,

        new: function (properties = {}, providerConfig = Config.emailGate.providers[Config.emailGate.active]) {
            const newModel = new this.__model__(properties);
            newModel.providerConfig = providerConfig;
            newModel.provider_name = newModel.providerConfig.name;
            newModel.provider = require(`./providers/${newModel.provider_name}`);
            newModel.provider.config(newModel.providerConfig);

            return Promise.resolve(Object.freeze(newModel));<commit_msg>BIG refactoring of email notification<commit_after>const Config                        = use('config');
const Property                      = use('core/property');

const NotificationEmailRepository   = require('./repository');
const EMAIL_STATUS                  = require('./enums/statuses');
const EMAIL_TYPE                    = require('./enums/types');


const NotificationEmailDefinition = {

    name: 'NotificationsEmail',

    repository: NotificationEmailRepository,

    properties: {
        id                      : Property.id(),
        message_id              : Property.string().max(255),
        provider_name           : Property.string(),
        accounts_senders_id     : Property.id(),
        sender_email            : Property.string().max(255),
        subject                 : Property.string().max(255),
        body                    : Property.string().max(64500),
        recipient_email_to      : Property.object(),
        recipient_email_cc      : Property.object(),
        recipient_email_bcc     : Property.object(),
        accounts_recipients_id  : Property.id(),
        status                  : Property.enum(Object.keys(EMAIL_STATUS)),
        type                    : Property.enum(Object.keys(EMAIL_TYPE))
    },

    factory: {
        EMAIL_STATUS,
        EMAIL_TYPE,

        new: function (properties = {}, providerConfig = Config.emailGate.providers[Config.emailGate.active]) {
            const newModel = new this.__model__(properties);
            newModel.providerConfig = providerConfig;
            newModel.provider_name = newModel.providerConfig.name;
            newModel.provider = require(`./providers/${newModel.provider_name}`);
            newModel.provider.config(newModel.providerConfig);

            return Promise.resolve(Object.freeze(newModel));
{'fraction_non_alphanumeric': 0.10771748022907009, 'fraction_numerical': 0.00763566948459231, 'mean_word_length': 1.9991823385118561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5438383', 'n_tokens_mistral': 925, 'n_tokens_neox': 885, 'n_words': 143}