def send_comment_notification(comment): talk = comment.talk for email, name in comment.notification_list(): if not PendingEmail.already_in_queue(email, talk): unsubscribe = url_for('talks.unsubscribe', token=talk.get_unsubscribe_token(email), _external=True) pending_email = PendingEmail( name=name, email=email, subject='[talks] New comment', body_text=render_template('email/notify.txt', name=name, email=email, talk=talk, unsubscribe=unsubscribe), body_html=render_template('email/notify.html', name=name, email=email, talk=talk, unsubscribe=unsubscribe), talk=talk) db.session.add(pending_email) db.session.flush() db.session.commit()
def send_author_notification(talk): if not PendingEmail.already_in_queue(talk.author.email, talk): pending_email = PendingEmail( name=talk.author.username, email=talk.author.email, subject='[talks] New comment', body_text=render_template('email/notify.txt', name=talk.author.username, email=talk.author.email, talk=talk), body_html=render_template('email/notify.html', name=talk.author.username, email=talk.author.email, talk=talk), talk=talk) db.session.add(pending_email) db.session.commit()