|
24 | 24 | from sentry.integrations.types import IntegrationProviderSlug |
25 | 25 | from sentry.integrations.utils.metrics import IntegrationWebhookEvent, IntegrationWebhookEventType |
26 | 26 | from sentry.integrations.utils.sync import sync_group_assignee_inbound |
| 27 | +from sentry.integrations.utils.webhook_viewer_context import webhook_viewer_context |
27 | 28 | from sentry.ratelimits.config import RateLimitConfig |
28 | 29 | from sentry.types.ratelimit import RateLimit, RateLimitCategory |
29 | 30 | from sentry.utils.email import parse_email |
@@ -173,24 +174,25 @@ def handle_status_change( |
173 | 174 | "status_change": status_change, |
174 | 175 | } |
175 | 176 | for org_integration in org_integrations: |
176 | | - installation = integration.get_installation( |
177 | | - organization_id=org_integration.organization_id |
178 | | - ) |
179 | | - if isinstance(installation, IssueSyncIntegration): |
180 | | - installation.sync_status_inbound( |
181 | | - external_issue_key, |
182 | | - { |
183 | | - "new_state": status_change["newValue"], |
184 | | - # old_state is None when the issue is New |
185 | | - "old_state": status_change.get("oldValue"), |
186 | | - "project": project, |
187 | | - }, |
188 | | - ) |
189 | | - else: |
190 | | - lifecycle.record_halt( |
191 | | - ProjectManagementHaltReason.SYNC_NON_SYNC_INTEGRATION_PROVIDED, |
192 | | - extra=logging_context, |
| 177 | + with webhook_viewer_context(org_integration.organization_id): |
| 178 | + installation = integration.get_installation( |
| 179 | + organization_id=org_integration.organization_id |
193 | 180 | ) |
| 181 | + if isinstance(installation, IssueSyncIntegration): |
| 182 | + installation.sync_status_inbound( |
| 183 | + external_issue_key, |
| 184 | + { |
| 185 | + "new_state": status_change["newValue"], |
| 186 | + # old_state is None when the issue is New |
| 187 | + "old_state": status_change.get("oldValue"), |
| 188 | + "project": project, |
| 189 | + }, |
| 190 | + ) |
| 191 | + else: |
| 192 | + lifecycle.record_halt( |
| 193 | + ProjectManagementHaltReason.SYNC_NON_SYNC_INTEGRATION_PROVIDED, |
| 194 | + extra=logging_context, |
| 195 | + ) |
194 | 196 |
|
195 | 197 |
|
196 | 198 | def handle_updated_workitem(data: Mapping[str, Any], integration: RpcIntegration) -> None: |
|
0 commit comments