|
12 | 12 | from rest_framework.exceptions import NotFound
|
13 | 13 | from rest_framework.request import Request
|
14 | 14 |
|
15 |
| -from sentry import audit_log, features |
16 |
| -from sentry.constants import ObjectStatus |
| 15 | +from sentry import audit_log |
17 | 16 | from sentry.exceptions import InvalidIdentity
|
18 | 17 | from sentry.identity.services.identity import identity_service
|
19 | 18 | from sentry.identity.services.identity.model import RpcIdentity
|
20 | 19 | from sentry.integrations.errors import OrganizationIntegrationNotFound
|
21 | 20 | from sentry.integrations.models.external_actor import ExternalActor
|
22 | 21 | from sentry.integrations.models.integration import Integration
|
23 |
| -from sentry.integrations.notify_disable import notify_disable |
24 | 22 | from sentry.integrations.pipeline_types import (
|
25 | 23 | IntegrationPipelineProviderT,
|
26 | 24 | IntegrationPipelineViewT,
|
27 | 25 | )
|
28 |
| -from sentry.integrations.request_buffer import IntegrationRequestBuffer |
29 | 26 | from sentry.integrations.types import IntegrationProviderSlug
|
30 | 27 | from sentry.models.team import Team
|
31 | 28 | from sentry.organizations.services.organization import (
|
|
48 | 45 | UnsupportedResponseType,
|
49 | 46 | )
|
50 | 47 | from sentry.users.models.identity import Identity
|
51 |
| -from sentry.utils.audit import create_audit_entry, create_system_audit_entry |
| 48 | +from sentry.utils.audit import create_audit_entry |
52 | 49 |
|
53 | 50 | if TYPE_CHECKING:
|
54 | 51 | from django.utils.functional import _StrPromise
|
@@ -540,69 +537,6 @@ def is_response_error(resp: Any) -> bool:
|
540 | 537 | return resp.status_code >= 400 and resp.status_code != 429 and resp.status_code < 500
|
541 | 538 |
|
542 | 539 |
|
543 |
| -def disable_integration( |
544 |
| - buffer: IntegrationRequestBuffer, redis_key: str, integration_id: int | None = None |
545 |
| -) -> None: |
546 |
| - from sentry.integrations.services.integration import integration_service |
547 |
| - |
548 |
| - result = integration_service.organization_contexts(integration_id=integration_id) |
549 |
| - rpc_integration = result.integration |
550 |
| - rpc_org_integrations = result.organization_integrations |
551 |
| - if rpc_integration and rpc_integration.status == ObjectStatus.DISABLED: |
552 |
| - return None |
553 |
| - |
554 |
| - org = None |
555 |
| - if len(rpc_org_integrations) > 0: |
556 |
| - org_context = organization_service.get_organization_by_id( |
557 |
| - id=rpc_org_integrations[0].organization_id, |
558 |
| - include_projects=False, |
559 |
| - include_teams=False, |
560 |
| - ) |
561 |
| - if org_context: |
562 |
| - org = org_context.organization |
563 |
| - |
564 |
| - extra = { |
565 |
| - "integration_id": integration_id, |
566 |
| - "buffer_record": buffer._get_all_from_buffer(), |
567 |
| - } |
568 |
| - extra["provider"] = "unknown" if rpc_integration is None else rpc_integration.provider |
569 |
| - extra["organization_id"] = ( |
570 |
| - "unknown" if len(rpc_org_integrations) == 0 else rpc_org_integrations[0].organization_id |
571 |
| - ) |
572 |
| - |
573 |
| - logger.info( |
574 |
| - "integration.disabled", |
575 |
| - extra=extra, |
576 |
| - ) |
577 |
| - |
578 |
| - if not rpc_integration: |
579 |
| - return None |
580 |
| - |
581 |
| - if org and ( |
582 |
| - ( |
583 |
| - rpc_integration.provider == IntegrationProviderSlug.SLACK |
584 |
| - and buffer.is_integration_fatal_broken() |
585 |
| - ) |
586 |
| - or (rpc_integration.provider == IntegrationProviderSlug.GITHUB) |
587 |
| - or ( |
588 |
| - features.has("organizations:gitlab-disable-on-broken", org) |
589 |
| - and rpc_integration.provider == IntegrationProviderSlug.GITLAB.value |
590 |
| - ) |
591 |
| - ): |
592 |
| - integration_service.update_integration( |
593 |
| - integration_id=rpc_integration.id, status=ObjectStatus.DISABLED |
594 |
| - ) |
595 |
| - notify_disable(org, rpc_integration.provider, redis_key) |
596 |
| - buffer.clear() |
597 |
| - create_system_audit_entry( |
598 |
| - organization_id=org.id, |
599 |
| - target_object=org.id, |
600 |
| - event=audit_log.get_event_id("INTEGRATION_DISABLED"), |
601 |
| - data={"provider": rpc_integration.provider}, |
602 |
| - ) |
603 |
| - return None |
604 |
| - |
605 |
| - |
606 | 540 | def get_integration_types(provider: str):
|
607 | 541 | types = []
|
608 | 542 | for integration_type, providers in INTEGRATION_TYPE_TO_PROVIDER.items():
|
|
0 commit comments