<commit_before>import json

from log import logger
from model import db, Notification, NotificationGroups, User, UserNotificationPair
from userManager import administration_required, token_required
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
from datetime import datetime
import env

class NotificationMgr:
    def __init__(self):
        logger.info("Notification Manager init...")
        try:
            Notification.query.all()
        except:
            db.create_all()
        try:
            NotificationGroups.query.all()
        except:
            db.create_all()
        try:
            UserNotificationPair.query.all()
        except:
            db.create_all()
        logger.info("Notification Manager init done!")

    def query_user_notifications(self, user):
        group_name = user.user_group
        notifies = NotificationGroups.query.filter_by(group_name=group_name).all()
        notifies.extend(NotificationGroups.query.filter_by(group_name='all').all())
        notify_ids = [notify.notification_id for notify in notifies]
        notify_ids = sorted(list(set(notify_ids)), reverse=True)
        return [Notification.query.filter_by(id=notify_id).first() for notify_id in notify_ids]

    def mail_notification(self, notify_id):
        email_from_address = env.getenv('EMAIL_FROM_ADDRESS')
        if (email_from_address in ['\'\'', '\"\"', '']):
            return {'success' : 'true'}
        notify = Notification.query.filter_by(id=notify_id).first()<commit_msg>use settings.get('E_MAIL_FROM_ADDRESS') to get e-mail address<commit_after>import json

from log import logger
from model import db, Notification, NotificationGroups, User, UserNotificationPair
from userManager import administration_required, token_required
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
from datetime import datetime
import env
from settings import settings

class NotificationMgr:
    def __init__(self):
        logger.info("Notification Manager init...")
        try:
            Notification.query.all()
        except:
            db.create_all()
        try:
            NotificationGroups.query.all()
        except:
            db.create_all()
        try:
            UserNotificationPair.query.all()
        except:
            db.create_all()
        logger.info("Notification Manager init done!")

    def query_user_notifications(self, user):
        group_name = user.user_group
        notifies = NotificationGroups.query.filter_by(group_name=group_name).all()
        notifies.extend(NotificationGroups.query.filter_by(group_name='all').all())
        notify_ids = [notify.notification_id for notify in notifies]
        notify_ids = sorted(list(set(notify_ids)), reverse=True)
        return [Notification.query.filter_by(id=notify_id).first() for notify_id in notify_ids]

    def mail_notification(self, notify_id):
        email_from_address = settings.get('EMAIL_FROM_ADDRESS')
        if (email_from_address in ['\'\'', '\"\"', '']):
            return {'success' : 'true'}
        notify = Notification.query.filter_by(id=notify_id).first()
{'fraction_non_alphanumeric': 0.09784615384615385, 'fraction_numerical': 0.0, 'mean_word_length': 3.189432989690722, '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': '4786762', 'n_tokens_mistral': 895, 'n_tokens_neox': 879, 'n_words': 204}