Repository: getsentry/sentry

Issue:
Convert billing attachments to use block kit
getsentry sometimes adds a billing attachment to a Slack notification (code [here](https://github.com/getsentry/sentry/blob/master/src/sentry/integrations/slack/actions/notification.py#L66-L71)) like letting the user know their Slack integration is about to be disabled (because a trial is ending, for example). This notification must be converted to block kit so that it can be added to the bottom of the notification. 

There is a screenshot of what that looks like in [this PR](https://github.com/getsentry/getsentry/pull/6717).


Discussion:

Resolving patch:
diff --git a/src/sentry/integrations/slack/actions/notification.py b/src/sentry/integrations/slack/actions/notification.py
--- a/src/sentry/integrations/slack/actions/notification.py
+++ b/src/sentry/integrations/slack/actions/notification.py
@@ -55,7 +55,6 @@ def after(
 
         def send_notification(event: GroupEvent, futures: Sequence[RuleFuture]) -> None:
             rules = [f.rule for f in futures]
-            # TODO: handle additional_attachments for block kit
             if features.has("organizations:slack-block-kit", event.group.project.organization):
                 blocks = build_group_attachment(
                     event.group,
@@ -64,6 +63,12 @@ def send_notification(event: GroupEvent, futures: Sequence[RuleFuture]) -> None:
                     rules=rules,
                     notification_uuid=notification_uuid,
                 )
+                additional_attachment = get_additional_attachment(
+                    integration, self.project.organization
+                )
+                if additional_attachment:
+                    for block in additional_attachment:
+                        blocks["blocks"].append(block)
 
                 if blocks.get("blocks"):
                     payload = {
diff --git a/src/sentry/integrations/slack/message_builder/base/block.py b/src/sentry/integrations/slack/message_builder/base/block.py
--- a/src/sentry/integrations/slack/message_builder/base/block.py
+++ b/src/sentry/integrations/slack/message_builder/base/block.py
@@ -76,6 +76,23 @@ def get_button_action(action):
 
         return button
 
+    @staticmethod
+    def get_link_button(action):
+        return {
+            "type": "section",
+            "text": {
+                "type": "mrkdwn",
+                "text": action.label,
+            },
+            "accessory": {
+                "type": "button",
+                "text": {"type": "plain_text", "text": action.name, "emoji": True},
+                "style": action.style,
+                "value": action.value,
+                "url": action.url,
+            },
+        }
+
     @staticmethod
     def get_action_block(actions: Sequence[Tuple[str, Optional[str], str]]) -> SlackBlock:
         class SlackBlockType(TypedDict):
diff --git a/src/sentry/integrations/slack/webhooks/action.py b/src/sentry/integrations/slack/webhooks/action.py
--- a/src/sentry/integrations/slack/webhooks/action.py
+++ b/src/sentry/integrations/slack/webhooks/action.py
@@ -500,8 +500,8 @@ def post(self, request: Request) -> Response:
 
         action_option = self.get_action_option(slack_request=slack_request)
 
-        # If a user is just clicking our auto response in the messages tab we just return a 200
-        if action_option == "sentry_docs_link_clicked":
+        # If a user is just clicking a button link we return a 200
+        if action_option in ("sentry_docs_link_clicked", "grace_period_warning"):
             return self.respond()
 
         if action_option in UNFURL_ACTION_OPTIONS:


Test patch: