Ejemplo n.º 1
0
def prepare_private_user_conversation_message_notification(user, messages):
    first_message = messages[0]
    conversation = first_message.conversation
    author = first_message.author
    reply_to_name = author.display_name

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

    unsubscribe_url = conversation_unsubscribe_url(author,
                                                   conversation=conversation)

    return prepare_email(
        template='conversation_message_notification',
        from_email=from_email,
        user=user,
        # TODO: which timezone? maybe the user needs a timezone?
        reply_to=[reply_to],
        unsubscribe_url=unsubscribe_url,
        context={
            'messages': messages,
            'conversation_name': author.display_name,
            'conversation_url': user_detail_url(author),
            'mute_url': unsubscribe_url,
        },
        stats_category='private_conversation_message',
    )
Ejemplo n.º 2
0
def prepare_private_user_conversation_message_notification(user, messages):
    with translation.override(language_for_user(user)):
        first_message = messages[0]
        author = first_message.author
        return prepare_message_notification(
            user,
            messages,
            conversation_name=author.display_name,
            conversation_url=user_detail_url(author),
            stats_category='private_conversation_message')