def get_context( notification: BaseNotification, recipient: Team | 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_recipient_context(recipient, extra_context), } # TODO(mgaeta): The unsubscribe system relies on `user_id` so it doesn't # work with Teams. We should add the `actor_id` to the signed link. unsubscribe_key = notification.get_unsubscribe_key() if isinstance(recipient, User) and unsubscribe_key: key, resource_id, referrer = unsubscribe_key context.update({ "unsubscribe_link": get_unsubscribe_link(recipient.id, resource_id, key, referrer) }) return context
def get_context( notification: BaseNotification, recipient: Union["Team", "User"], 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_recipient_context(recipient, extra_context), }