Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/firetower/slack_app/handlers/dumpslack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,25 @@
logger = logging.getLogger(__name__)


_PRIVATE_INCIDENT_PM_MESSAGE = (
"Postmortem doc generation is disabled for private incidents. "
"We are working on a better flow for private incidents, but for now, "
"please create a private postmortem document, share it with the "
"appropriate people, and link it in the Firetower incident description."
)


def _trigger_slack_dump(client: Any, channel_id: str, incident: Any) -> None:
if incident.is_private:
try:
client.chat_postMessage(
channel=channel_id, text=_PRIVATE_INCIDENT_PM_MESSAGE
)
except Exception:
logger.exception(
"Failed to post private incident PM message to channel %s",
channel_id,
)
Comment thread
spalmurray marked this conversation as resolved.
return

notion = NotionService.from_settings()
Expand Down Expand Up @@ -231,12 +248,7 @@
return

if incident.is_private:
respond(
"Postmortem doc generation is disabled for private incidents. "
"We are working on a better flow for private incidents, but for now, "
"please create a private postmortem document, share it with the "
"appropriate people, and link it in the Firetower incident description."
)
respond(_PRIVATE_INCIDENT_PM_MESSAGE)

Check warning on line 251 in src/firetower/slack_app/handlers/dumpslack.py

View check run for this annotation

@sentry/warden / warden: find-bugs

respond() still sends an ephemeral message despite PR's intent to make it public

The PR intends to make this message public (channel-visible), but `respond()` without `response_type="in_channel"` sends an ephemeral message only visible to the invoking user — the behavior is unchanged from before.
Comment thread
spalmurray marked this conversation as resolved.
return

respond(
Expand Down
2 changes: 1 addition & 1 deletion src/firetower/slack_app/handlers/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def handle_help_command(ack: Any, command: dict, respond: Any) -> None:
f" `{cmd} mitigated` - Mark incident as mitigated (alias: `{cmd} mit`)\n"
f" `{cmd} resolved` - Mark incident as resolved (alias: `{cmd} fixed`)\n"
f" `{cmd} statuspage` - Create or update a statuspage post\n"
f" `{cmd} dumpslack` - Dump slack channel history (not yet implemented)\n"
f" `{cmd} dumpslack` - Update slack transcript in postmortem doc\n"
f" `{cmd} reopen` - Reopen an incident\n"
)
7 changes: 5 additions & 2 deletions src/firetower/slack_app/tests/handlers/test_dumpslack.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def test_returns_none_for_non_image_content_type(self):


class TestTriggerSlackDump:
def test_skips_silently_for_private_incident(self):
def test_posts_guidance_and_skips_notion_for_private_incident(self):
client = MagicMock()
mock_incident = MagicMock()
mock_incident.is_private = True
Expand All @@ -457,7 +457,10 @@ def test_skips_silently_for_private_incident(self):
_trigger_slack_dump(client, "C123", mock_incident)

mock_notion.assert_not_called()
client.chat_postMessage.assert_not_called()
client.chat_postMessage.assert_called_once()
posted = client.chat_postMessage.call_args[1]["text"]
assert "private" in posted.lower()
assert "C123" == client.chat_postMessage.call_args[1]["channel"]

def test_skips_silently_when_notion_not_configured(self):
client = MagicMock()
Expand Down
Loading