Exemplo n.º 1
0
def prepare_group_conversation_message_notification(user, message):
    conversation = message.conversation
    group = conversation.target

    from_text = message.author.display_name
    reply_to_name = group.name
    conversation_name = group.name

    local_part = make_local_part(conversation, user, message)
    reply_to = formataddr(
        (reply_to_name, '{}@{}'.format(local_part,
                                       settings.SPARKPOST_RELAY_DOMAIN)))
    from_email = formataddr((from_text, settings.DEFAULT_FROM_EMAIL))

    unsubscribe_url = conversation_unsubscribe_url(user,
                                                   group=group,
                                                   conversation=conversation)

    return prepare_email(
        template='conversation_message_notification',
        from_email=from_email,
        user=user,
        tz=group.timezone,
        reply_to=[reply_to],
        unsubscribe_url=unsubscribe_url,
        context={
            'messages': [message],
            'conversation_name': conversation_name,
            'conversation_url': group_wall_url(group),
            'mute_url': unsubscribe_url,
        },
        stats_category='group_conversation_message',
    )
Exemplo n.º 2
0
def prepare_application_accepted_email(application):
    return prepare_email(template='application_accepted',
                         user=application.user,
                         tz=application.group.timezone,
                         context={
                             'group': application.group,
                             'group_url': group_wall_url(application.group)
                         })
Exemplo n.º 3
0
def prepare_user_became_editor_email(user, group):
    return prepare_email(
        template='user_became_editor',
        user=user,
        tz=group.timezone,
        context={
            'group_name': group.name,
            'group_url': group_wall_url(group),
        },
    )
Exemplo n.º 4
0
def prepare_user_inactive_in_group_email(user, group):
    return prepare_email(
        template='user_inactive_in_group',
        user=user,
        tz=group.timezone,
        context={
            'group_name': group.name,
            'group_url': group_wall_url(group),
            'num_days_inactive': settings.NUMBER_OF_DAYS_UNTIL_INACTIVE_IN_GROUP,
        },
    )
Exemplo n.º 5
0
def prepare_user_lost_editor_role_email(user, group):
    return prepare_email(
        template='user_lost_editor_role',
        user=user,
        tz=group.timezone,
        context={
            'group_name': group.name,
            'group_url': group_wall_url(group),
            'group': group,
        },
        stats_category='user_lost_editor_role',
    )
Exemplo n.º 6
0
def prepare_user_removal_from_group_email(user, group):
    return prepare_email(
        template='user_removal_from_group',
        user=user,
        tz=group.timezone,
        context={
            'group_name': group.name,
            'group_url': group_wall_url(group),
            'num_months_inactive': settings.NUMBER_OF_INACTIVE_MONTHS_UNTIL_REMOVAL_FROM_GROUP_NOTIFICATION,
            'num_removal_days': settings.NUMBER_OF_DAYS_AFTER_REMOVAL_NOTIFICATION_WE_ACTUALLY_REMOVE_THEM,
        },
    )
Exemplo n.º 7
0
def prepare_group_conversation_message_notification(user, message):
    conversation = message.conversation
    group = conversation.target
    reply_to_name = group.name
    conversation_name = group.name
    with translation.override(language_for_user(user)):
        return prepare_message_notification(
            user,
            messages=[message],
            group=group,
            reply_to_name=reply_to_name,
            conversation_name=conversation_name,
            conversation_url=group_wall_url(group),
            stats_category='group_conversation_message')