def prepare_group_conversation_message_notification(user, messages): first_message = messages[0] conversation = first_message.conversation group = conversation.target from_text = author_names(messages) reply_to_name = group.name conversation_name = group.name local_part = make_local_part(conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr((from_text, settings.DEFAULT_FROM_EMAIL)) return prepare_email(template='conversation_message_notification', from_email=from_email, user=user, reply_to=[reply_to], context={ 'messages': messages, 'conversation_name': conversation_name, 'conversation_url': group_wall_url(group), 'mute_url': group_conversation_mute_url(group, conversation), })
def prepare_application_accepted_email(application): return prepare_email(template='application_accepted', user=application.user, context={ 'group': application.group, 'group_url': group_wall_url(application.group) })
def prepare_group_conversation_message_notification(user, message): group = message.conversation.target reply_to_name = group.name conversation_name = group.name local_part = make_local_part(message.conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr( (message.author.display_name, settings.DEFAULT_FROM_EMAIL)) return prepare_email('conversation_message_notification', from_email=from_email, user=user, reply_to=[reply_to], context={ 'conversation_name': conversation_name, 'author': message.author, 'message_content': message.content_rendered(), 'conversation_url': group_wall_url(group), 'mute_url': group_conversation_mute_url( group, message.conversation), })
def prepare_user_became_editor_email(user, group): return prepare_email( template='user_became_editor', user=user, context={ 'group_name': group.name, 'group_url': group_wall_url(group), }, )
def prepare_user_inactive_in_group_email(user, group): return prepare_email( template='user_inactive_in_group', user=user, context={ 'group_name': group.name, 'group_url': group_wall_url(group), 'num_days_inactive': settings.NUMBER_OF_DAYS_UNTIL_INACTIVE_IN_GROUP, }, )
def prepare_conversation_message_notification(user, message): if not isinstance(message.conversation.target, Group): raise Exception( 'Cannot send message notification if conversation does not belong to a group' ) group = message.conversation.target reply_to_name = group.name conversation_name = group.name local_part = make_local_part(message.conversation, user) reply_to = formataddr( (reply_to_name, '{}@{}'.format(local_part, settings.SPARKPOST_RELAY_DOMAIN))) from_email = formataddr( (message.author.display_name, settings.DEFAULT_FROM_EMAIL)) with translation.override(user.language): return prepare_email('conversation_message_notification', from_email=from_email, user=user, reply_to=[reply_to], context={ 'conversation_name': conversation_name, 'author': message.author, 'message_content': message.content_rendered(), 'conversation_url': group_wall_url(group), 'mute_url': conversation_mute_url(group, message.conversation) })