def send_email_to_added_members(blog, recipients, blog_url): prefs_service = get_resource_service('preferences') recipients_email = [] for user in recipients: # If user want to receive email notification, we add him as recipient. if prefs_service.email_notification_is_enabled(user_id=user): if isinstance(user, ObjectId): user_doc = get_resource_service('users').find_one( req=None, _id=ObjectId(user)) else: user_doc = get_resource_service('users').find_one( req=None, _id=ObjectId(user['user'])) recipients_email.append(user_doc['email']) if recipients_email: # Send emails. title = blog['title'] admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("invited_members_subject.txt", app_name=app_name) text_body = render_template("invited_members.txt", app_name=app_name, link=blog_url, title=title) html_body = render_template("invited_members.html", app_name=app_name, link=blog_url, title=title) if not app.config.get('SUPERDESK_TESTING', False): send_email.delay(subject=subject, sender=admins[0], recipients=recipients_email, text_body=text_body, html_body=html_body)
def send_email_to_owner(doc, owner, origin): blog = get_resource_service('blogs').find_one(req=None, _id=doc.get('blog')) prefs_service = get_resource_service('preferences') recipients = None original_creator = doc['original_creator'] if prefs_service.email_notification_is_enabled(user_id=original_creator): user_doc = get_resource_service('users').find_one(req=None, _id=original_creator) if user_doc: recipients = [user_doc['email']] if recipients: username = g.user.get('display_name') or g.user.get('username') url = '{}/#/liveblog/settings/{}'.format(origin, doc['_id']) title = blog['title'] admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("owner_email_subject.txt", app_name=app_name) text_body = render_template("owner_request.txt", app_name=app_name, link=url, name_of_user=username, title=title) html_body = render_template("owner_request.html", app_name=app_name, link=url, name_of_user=username, title=title) send_email.delay(subject=subject, sender=admins[0], recipients=recipients, text_body=text_body, html_body=html_body)
def send_email_to_added_members(blog, recipients, origin): prefs_service = get_resource_service('preferences') recipients_email = [] for user in recipients: # if user want to receive email notification, we add him as recipient if prefs_service.email_notification_is_enabled(user_id=user): if isinstance(user, ObjectId): user_doc = get_resource_service('users').find_one( req=None, _id=ObjectId(user)) else: user_doc = get_resource_service('users').find_one( req=None, _id=ObjectId(user['user'])) recipients_email.append(user_doc['email']) if recipients_email: # send emails url = '{}/#/liveblog/edit/{}'.format(origin, blog['_id']) title = blog['title'] admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("invited_members_subject.txt", app_name=app_name) text_body = render_template("invited_members.txt", app_name=app_name, link=url, title=title) html_body = render_template("invited_members.html", app_name=app_name, link=url, title=title) send_email.delay(subject=subject, sender=admins[0], recipients=recipients_email, text_body=text_body, html_body=html_body)
def send_members_email(recipients, user_name, doc, title, url): admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("invited_members_subject.txt", app_name=app_name) text_body = render_template("invited_members.txt", link=url, title=title) html_body = render_template("invited_members.html", link=url, title=title) send_email.delay(subject=subject, sender=admins[0], recipients=recipients, text_body=text_body, html_body=html_body)
def send_reset_password_email(doc): from settings import ADMINS from flask import render_template send_email.delay(subject='Reset password', sender=ADMINS[0], recipients=[doc['email']], text_body=render_template("reset_password.txt", user=doc, expires=token_ttl), html_body=render_template("reset_password.html", user=doc, expires=token_ttl))
def send_email_to_owner(doc, owner, origin): blog = get_resource_service('blogs').find_one(req=None, _id=doc.get('blog')) prefs_service = get_resource_service('preferences') if prefs_service.email_notification_is_enabled(user_id=doc['original_creator']): user_doc = get_resource_service('users').find_one(req=None, _id=doc['original_creator']) recipients = user_doc['email'] if recipients: username = g.user.get('display_name') or g.user.get('username') url = '{}/#/liveblog/settings/{}'.format(origin, doc['_id']) title = blog['title'] admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("owner_email_subject.txt", app_name=app_name) text_body = render_template("owner_request.txt", app_name=app_name, link=url, name_of_user=username, title=title) html_body = render_template("owner_request.html", app_name=app_name, link=url, name_of_user=username, title=title) send_email.delay(subject=subject, sender=admins[0], recipients=recipients, text_body=text_body, html_body=html_body)
def send_email_to_added_members(blog, recipients, origin): prefs_service = get_resource_service('preferences') recipients_email = [] for user in recipients: # if user want to receive email notification, we add him as recipient if prefs_service.email_notification_is_enabled(user_id=user['user']): user_doc = get_resource_service('users').find_one(req=None, _id=user['user']) recipients_email.append(user_doc['email']) if recipients_email: # send emails url = '{}/#/liveblog/edit/{}'.format(origin, blog['_id']) title = blog['title'] admins = app.config['ADMINS'] app_name = app.config['APPLICATION_NAME'] subject = render_template("invited_members_subject.txt", app_name=app_name) text_body = render_template("invited_members.txt", app_name=app_name, link=url, title=title) html_body = render_template("invited_members.html", app_name=app_name, link=url, title=title) send_email.delay(subject=subject, sender=admins[0], recipients=recipients_email, text_body=text_body, html_body=html_body)
def send_reset_password_email(self, doc): send_email.delay(subject='Reset password', sender=ADMINS[0], recipients=[doc['email']], text_body=render_template("reset_password.txt", user=doc, expires=token_ttl), html_body=render_template("reset_password.html", user=doc, expires=token_ttl))
def _send_user_status_changed_email(self, recipients, status): send_email.delay(subject='Your Superdesk account is %s' % status, sender=ADMINS[0], recipients=recipients, text_body=render_template("account_status_changed.txt", status=status), html_body=render_template("account_status_changed.html", status=status))