prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Convert digest notifications to use block kit
  Convert the `DigestNotificationMessageBuilder` (code [here](https://github.com/getsentry/sentry/blob/master/src/sentry/integrations/slack/message_builder/notifications/digest.py)) to use block kit. This may be harder to test as I have personally never received one.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/sentry/integrations/slack/message_builder/notifications/digest.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from typing import Any, Mapping
  4 
  5 from sentry.digests import Digest
  6 from sentry.digests.utils import get_groups
  7 from sentry.integrations.slack.message_builder import SlackBody
  8 from sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder
  9 from sentry.notifications.notifications.digest import DigestNotification
  10 from sentry.services.hybrid_cloud.actor import RpcActor
  11 
  12 from .base import SlackNotificationsMessageBuilder
  13 
  14 
  15 class DigestNotificationMessageBuilder(SlackNotificationsMessageBuilder):
  16     def __init__(
  17         self,
  18         notification: DigestNotification,
  19         context: Mapping[str, Any],
  20         recipient: RpcActor,
  21     ) -> None:
  22         super().__init__(notification, context, recipient)
  23         self.notification: DigestNotification = notification
  24 
  25     def build(self) -> SlackBody:
  26         """
  27         It's currently impossible in mypy to have recursive types so we need a
  28         hack to get this to return a SlackBody.
  29         """
  30         digest: Digest = self.context.get("digest", {})
  31         return [
  32             SlackIssuesMessageBuilder(
  33                 group=group,
  34                 event=event,
  35                 rules=[rule],
  36                 issue_details=True,
  37                 notification=self.notification,
  38                 recipient=self.recipient,
  39             ).build()
  40             for rule, group, event in get_groups(digest)
  41         ]
  42
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/sentry/integrations/slack/message_builder/notifications/digest.py b/src/sentry/integrations/slack/message_builder/notifications/digest.py
  --- a/src/sentry/integrations/slack/message_builder/notifications/digest.py
  +++ b/src/sentry/integrations/slack/message_builder/notifications/digest.py
  @@ -2,9 +2,10 @@
   
   from typing import Any, Mapping
   
  +from sentry import features
   from sentry.digests import Digest
   from sentry.digests.utils import get_groups
  -from sentry.integrations.slack.message_builder import SlackBody
  +from sentry.integrations.slack.message_builder import SlackAttachment, SlackBlock
   from sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder
   from sentry.notifications.notifications.digest import DigestNotification
   from sentry.services.hybrid_cloud.actor import RpcActor
  @@ -22,14 +23,28 @@
           super().__init__(notification, context, recipient)
           self.notification: DigestNotification = notification
   
  -    def build(self) -> SlackBody:
  +    def build(self) -> SlackAttachment | SlackBlock:
           """
           It's currently impossible in mypy to have recursive types so we need a
           hack to get this to return a SlackBody.
           """
           digest: Digest = self.context.get("digest", {})
  -        return [
  -            SlackIssuesMessageBuilder(
  +        digest_groups = get_groups(digest)
  +        if not features.has("organizations:slack-block-kit", self.notification.organization):
  +            return [
  +                SlackIssuesMessageBuilder(
  +                    group=group,
  +                    event=event,
  +                    rules=[rule],
  +                    issue_details=True,
  +                    notification=self.notification,
  +                    recipient=self.recipient,
  +                ).build()
  +                for rule, group, event in digest_groups
  +            ]
  +        blocks = []
  +        for rule, group, event in digest_groups:
  +            alert_as_blocks = SlackIssuesMessageBuilder(
                   group=group,
                   event=event,
                   rules=[rule],
  @@ -37,5 +52,8 @@
                   notification=self.notification,
                   recipient=self.recipient,
               ).build()
  -            for rule, group, event in get_groups(digest)
  -        ]
  +            # we iterate through the list of blocks created for each alert in the digest and add
  +            # each block to the list of blocks which is used for the entire digest notification
  +            for block in alert_as_blocks.get("blocks"):
  +                blocks.append(block)
  +        return self._build_blocks(*blocks)
  
verification_info: {"golden_diff": "diff --git a/src/sentry/integrations/slack/message_builder/notifications/digest.py b/src/sentry/integrations/slack/message_builder/notifications/digest.py\n--- a/src/sentry/integrations/slack/message_builder/notifications/digest.py\n+++ b/src/sentry/integrations/slack/message_builder/notifications/digest.py\n@@ -2,9 +2,10 @@\n \n from typing import Any, Mapping\n \n+from sentry import features\n from sentry.digests import Digest\n from sentry.digests.utils import get_groups\n-from sentry.integrations.slack.message_builder import SlackBody\n+from sentry.integrations.slack.message_builder import SlackAttachment, SlackBlock\n from sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder\n from sentry.notifications.notifications.digest import DigestNotification\n from sentry.services.hybrid_cloud.actor import RpcActor\n@@ -22,14 +23,28 @@\n         super().__init__(notification, context, recipient)\n         self.notification: DigestNotification = notification\n \n-    def build(self) -> SlackBody:\n+    def build(self) -> SlackAttachment | SlackBlock:\n         \"\"\"\n         It's currently impossible in mypy to have recursive types so we need a\n         hack to get this to return a SlackBody.\n         \"\"\"\n         digest: Digest = self.context.get(\"digest\", {})\n-        return [\n-            SlackIssuesMessageBuilder(\n+        digest_groups = get_groups(digest)\n+        if not features.has(\"organizations:slack-block-kit\", self.notification.organization):\n+            return [\n+                SlackIssuesMessageBuilder(\n+                    group=group,\n+                    event=event,\n+                    rules=[rule],\n+                    issue_details=True,\n+                    notification=self.notification,\n+                    recipient=self.recipient,\n+                ).build()\n+                for rule, group, event in digest_groups\n+            ]\n+        blocks = []\n+        for rule, group, event in digest_groups:\n+            alert_as_blocks = SlackIssuesMessageBuilder(\n                 group=group,\n                 event=event,\n                 rules=[rule],\n@@ -37,5 +52,8 @@\n                 notification=self.notification,\n                 recipient=self.recipient,\n             ).build()\n-            for rule, group, event in get_groups(digest)\n-        ]\n+            # we iterate through the list of blocks created for each alert in the digest and add\n+            # each block to the list of blocks which is used for the entire digest notification\n+            for block in alert_as_blocks.get(\"blocks\"):\n+                blocks.append(block)\n+        return self._build_blocks(*blocks)\n", "issue": "Convert digest notifications to use block kit\nConvert the `DigestNotificationMessageBuilder` (code [here](https://github.com/getsentry/sentry/blob/master/src/sentry/integrations/slack/message_builder/notifications/digest.py)) to use block kit. This may be harder to test as I have personally never received one.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any, Mapping\n\nfrom sentry.digests import Digest\nfrom sentry.digests.utils import get_groups\nfrom sentry.integrations.slack.message_builder import SlackBody\nfrom sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder\nfrom sentry.notifications.notifications.digest import DigestNotification\nfrom sentry.services.hybrid_cloud.actor import RpcActor\n\nfrom .base import SlackNotificationsMessageBuilder\n\n\nclass DigestNotificationMessageBuilder(SlackNotificationsMessageBuilder):\n    def __init__(\n        self,\n        notification: DigestNotification,\n        context: Mapping[str, Any],\n        recipient: RpcActor,\n    ) -> None:\n        super().__init__(notification, context, recipient)\n        self.notification: DigestNotification = notification\n\n    def build(self) -> SlackBody:\n        \"\"\"\n        It's currently impossible in mypy to have recursive types so we need a\n        hack to get this to return a SlackBody.\n        \"\"\"\n        digest: Digest = self.context.get(\"digest\", {})\n        return [\n            SlackIssuesMessageBuilder(\n                group=group,\n                event=event,\n                rules=[rule],\n                issue_details=True,\n                notification=self.notification,\n                recipient=self.recipient,\n            ).build()\n            for rule, group, event in get_groups(digest)\n        ]\n", "path": "src/sentry/integrations/slack/message_builder/notifications/digest.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any, Mapping\n\nfrom sentry import features\nfrom sentry.digests import Digest\nfrom sentry.digests.utils import get_groups\nfrom sentry.integrations.slack.message_builder import SlackAttachment, SlackBlock\nfrom sentry.integrations.slack.message_builder.issues import SlackIssuesMessageBuilder\nfrom sentry.notifications.notifications.digest import DigestNotification\nfrom sentry.services.hybrid_cloud.actor import RpcActor\n\nfrom .base import SlackNotificationsMessageBuilder\n\n\nclass DigestNotificationMessageBuilder(SlackNotificationsMessageBuilder):\n    def __init__(\n        self,\n        notification: DigestNotification,\n        context: Mapping[str, Any],\n        recipient: RpcActor,\n    ) -> None:\n        super().__init__(notification, context, recipient)\n        self.notification: DigestNotification = notification\n\n    def build(self) -> SlackAttachment | SlackBlock:\n        \"\"\"\n        It's currently impossible in mypy to have recursive types so we need a\n        hack to get this to return a SlackBody.\n        \"\"\"\n        digest: Digest = self.context.get(\"digest\", {})\n        digest_groups = get_groups(digest)\n        if not features.has(\"organizations:slack-block-kit\", self.notification.organization):\n            return [\n                SlackIssuesMessageBuilder(\n                    group=group,\n                    event=event,\n                    rules=[rule],\n                    issue_details=True,\n                    notification=self.notification,\n                    recipient=self.recipient,\n                ).build()\n                for rule, group, event in digest_groups\n            ]\n        blocks = []\n        for rule, group, event in digest_groups:\n            alert_as_blocks = SlackIssuesMessageBuilder(\n                group=group,\n                event=event,\n                rules=[rule],\n                issue_details=True,\n                notification=self.notification,\n                recipient=self.recipient,\n            ).build()\n            # we iterate through the list of blocks created for each alert in the digest and add\n            # each block to the list of blocks which is used for the entire digest notification\n            for block in alert_as_blocks.get(\"blocks\"):\n                blocks.append(block)\n        return self._build_blocks(*blocks)\n", "path": "src/sentry/integrations/slack/message_builder/notifications/digest.py"}]}