Ejemplo n.º 1
0
def get_context(
    notification: BaseNotification,
    recipient: Union[User, Team],
    shared_context: Mapping[str, Any],
    extra_context: Mapping[str, Any],
) -> Mapping[str, Any]:
    """Compose the various levels of context and add Slack-specific fields."""
    return {
        **shared_context,
        **notification.get_user_context(recipient, extra_context),
    }
Ejemplo n.º 2
0
def get_context(
    notification: BaseNotification,
    user: User,
    shared_context: Mapping[str, Any],
    extra_context: Mapping[str, Any],
) -> Mapping[str, Any]:
    """
    Compose the various levels of context and add email-specific fields. The
    generic HTML/text templates only render the unsubscribe link if one is
    present in the context, so don't automatically add it to every message.
    """
    context = {
        **shared_context,
        **notification.get_user_context(user, extra_context),
    }
    if notification.get_unsubscribe_key():
        key, resource_id, referrer = notification.get_unsubscribe_key()
        context.update({
            "unsubscribe_link":
            get_unsubscribe_link(user.id, resource_id, key, referrer)
        })

    return context