:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(notifications): skip inactive email recipients (#119434)
Richard Solomou2c20b7ddc4a1
diff --git a/posthog/tasks/email.py b/posthog/tasks/email.pyindex c742a565c708..edb748ced52d 100644--- a/posthog/tasks/email.py+++ b/posthog/tasks/email.py@@ -112,7 +112,7 @@ def get_members_to_notify(team: Team, notification_setting: NotificationSettingTmemberships_to_email = []memberships = list(OrganizationMembership.objects.prefetch_related("user", "organization").filter(- organization_id=team.organization_id+ organization_id=team.organization_id, user__is_active=True))# Resolved once, or this is a query per member on every fan-out.diff --git a/posthog/tasks/test/test_email.py b/posthog/tasks/test/test_email.pyindex 5143f8e4d46b..13964c92c1cc 100644--- a/posthog/tasks/test/test_email.py+++ b/posthog/tasks/test/test_email.py@@ -1457,6 +1457,7 @@ class TestEmail(APIBaseTest, ClickhouseTestMixin):def test_send_hog_functions_digest_email(self, MockEmailMessage: MagicMock) -> None:mocked_email_messages = mock_email_messages(MockEmailMessage)+ self._create_user("[email protected]", is_active=False)digest_data = {"team_id": self.team.id,@@ -1491,6 +1492,7 @@ class TestEmail(APIBaseTest, ClickhouseTestMixin):send_hog_functions_digest_email(digest_data)assert len(mocked_email_messages) == 1+ assert mocked_email_messages[0].to[0]["raw_email"] == self.user.emailassert mocked_email_messages[0].send.call_count == 1assert mocked_email_messages[0].html_body