Skip to content
Open
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
16 changes: 14 additions & 2 deletions readthedocs/api/v2/views/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from textwrap import dedent

import structlog
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils.crypto import constant_time_compare
from rest_framework import permissions
Expand Down Expand Up @@ -203,11 +204,22 @@ def get_integration(self):
# in `WebhookView`
if self.integration is not None:
return self.integration
self.integration = get_object_or_404(
Integration,

integrations = Integration.objects.filter(
project=self.project,
integration_type=self.integration_type,
)

count = integrations.count()
if count == 0:
raise Http404("No Integration matches the given query.")
elif count > 1:
raise ParseError(
"Multiple integrations found for this project. "
"Please use the webhook URL specific to your integration."
)

self.integration = integrations.first()
return self.integration

def get_response_push(self, project, versions_info: list[VersionInfo]):
Expand Down
Loading