def send_notifications(user_profiles, subject, text_body, html_body=None, response_callback=None, sender=None, notification_category=''): """Asynchronously send email notifications to users html_body - optional html body for the notification response_callback - url called when a user responds to a notification If response_callback is None, it is assumed that the notification cannot be responded to sender - the name to be used in the from address: sender <reply+token@domain> """ token = None if (response_callback): token = ResponseToken(response_callback=response_callback) token.save() ff = lambda p: filter_user_notification(p, notification_category) user_profiles = filter(ff, user_profiles) from_email = _prepare_from_address(sender, token) args = (user_profiles, subject, text_body, html_body, from_email) #log.debug(u"notifications.send_notifications: {0}".format(args)) SendNotifications.apply_async(args)
def send_notifications(user_profiles, subject_template, body_template, template_context, response_callback=None, sender=None): """Asynchronously send email notifications to users user_profiles - the users to send the notification to subject_template - the template to use for the subject body_template - the template to use for the body template_context - the context to use when rendering the template response_callback - url called when a user responds to a notification If response_callback is None, it is assumed that the notification cannot be responded to sender - the name to be used in the from address: sender <reply+token@domain> """ token_text = None if (response_callback): token = ResponseToken() token.response_callback = response_callback token.save() token_text = token.response_token args = (user_profiles, subject_template, body_template, template_context, token_text, sender) log.debug("notifications.send_notifications: {0}".format(args)) SendNotifications.apply_async(args)
def send_notifications(user_profiles, subject, text_body, html_body=None, response_callback=None, sender=None): """Asynchronously send email notifications to users html_body - optional html body for the notification response_callback - url called when a user responds to a notification If response_callback is None, it is assumed that the notification cannot be responded to sender - the name to be used in the from address: sender <reply+token@domain> """ token = None if (response_callback): token = ResponseToken(response_callback=response_callback) token.save() from_email = _prepare_from_address(sender, token) args = (user_profiles, subject, text_body, html_body, from_email) log.debug(u"notifications.send_notifications: {0}".format(args)) SendNotifications.apply_async(args)