forked from github/plane
Merge branch 'chore/api_endpoints' of github.com:makeplane/plane into chore/api_endpoints
This commit is contained in:
commit
bc0c9404a4
@ -42,24 +42,6 @@ class WebhookMixin:
|
|||||||
def finalize_response(self, request, response, *args, **kwargs):
|
def finalize_response(self, request, response, *args, **kwargs):
|
||||||
response = super().finalize_response(request, response, *args, **kwargs)
|
response = super().finalize_response(request, response, *args, **kwargs)
|
||||||
|
|
||||||
# Check for the case should webhook be sent
|
|
||||||
if (
|
|
||||||
self.webhook_event
|
|
||||||
and self.request.method in ["POST", "PATCH"]
|
|
||||||
and response.status_code in [200, 201, 204]
|
|
||||||
):
|
|
||||||
# Get the id
|
|
||||||
object_id = (
|
|
||||||
response.data.get("id") if isinstance(response.data, dict) else None
|
|
||||||
)
|
|
||||||
# Push the object to delay
|
|
||||||
send_webhook.delay(
|
|
||||||
event=self.webhook_event,
|
|
||||||
event_id=object_id,
|
|
||||||
action=self.request.method,
|
|
||||||
slug=self.workspace_slug,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check for the case should webhook be sent
|
# Check for the case should webhook be sent
|
||||||
if (
|
if (
|
||||||
self.webhook_event
|
self.webhook_event
|
||||||
|
@ -310,7 +310,7 @@ class CycleIssueAPIEndpoint(WebhookMixin, BaseAPIView):
|
|||||||
|
|
||||||
serializer_class = CycleIssueSerializer
|
serializer_class = CycleIssueSerializer
|
||||||
model = CycleIssue
|
model = CycleIssue
|
||||||
webhook_event = "cycle"
|
webhook_event = "cycle_issue"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectEntityPermission,
|
ProjectEntityPermission,
|
||||||
]
|
]
|
||||||
|
@ -450,7 +450,7 @@ class IssueCommentAPIEndpoint(WebhookMixin, BaseAPIView):
|
|||||||
|
|
||||||
serializer_class = IssueCommentSerializer
|
serializer_class = IssueCommentSerializer
|
||||||
model = IssueComment
|
model = IssueComment
|
||||||
webhook_event = "issue-comment"
|
webhook_event = "issue_comment"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectLitePermission,
|
ProjectLitePermission,
|
||||||
]
|
]
|
||||||
|
@ -194,7 +194,7 @@ class ModuleIssueAPIEndpoint(WebhookMixin, BaseAPIView):
|
|||||||
|
|
||||||
serializer_class = ModuleIssueSerializer
|
serializer_class = ModuleIssueSerializer
|
||||||
model = ModuleIssue
|
model = ModuleIssue
|
||||||
webhook_event = "module"
|
webhook_event = "module_issue"
|
||||||
|
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectEntityPermission,
|
ProjectEntityPermission,
|
||||||
|
@ -502,7 +502,7 @@ class CycleViewSet(WebhookMixin, BaseViewSet):
|
|||||||
class CycleIssueViewSet(WebhookMixin, BaseViewSet):
|
class CycleIssueViewSet(WebhookMixin, BaseViewSet):
|
||||||
serializer_class = CycleIssueSerializer
|
serializer_class = CycleIssueSerializer
|
||||||
model = CycleIssue
|
model = CycleIssue
|
||||||
webhook_event = "cycle"
|
webhook_event = "cycle_issue"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectEntityPermission,
|
ProjectEntityPermission,
|
||||||
]
|
]
|
||||||
|
@ -596,7 +596,7 @@ class IssueActivityEndpoint(BaseAPIView):
|
|||||||
class IssueCommentViewSet(WebhookMixin, BaseViewSet):
|
class IssueCommentViewSet(WebhookMixin, BaseViewSet):
|
||||||
serializer_class = IssueCommentSerializer
|
serializer_class = IssueCommentSerializer
|
||||||
model = IssueComment
|
model = IssueComment
|
||||||
webhook_event = "issue-comment"
|
webhook_event = "issue_comment"
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
ProjectLitePermission,
|
ProjectLitePermission,
|
||||||
]
|
]
|
||||||
|
@ -283,9 +283,10 @@ class ModuleViewSet(WebhookMixin, BaseViewSet):
|
|||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
class ModuleIssueViewSet(BaseViewSet):
|
class ModuleIssueViewSet(WebhookMixin, BaseViewSet):
|
||||||
serializer_class = ModuleIssueSerializer
|
serializer_class = ModuleIssueSerializer
|
||||||
model = ModuleIssue
|
model = ModuleIssue
|
||||||
|
webhook_event = "module_issue"
|
||||||
|
|
||||||
filterset_fields = [
|
filterset_fields = [
|
||||||
"issue__labels__id",
|
"issue__labels__id",
|
||||||
|
@ -176,13 +176,13 @@ def send_webhook(event, event_id, action, slug):
|
|||||||
if event == "issue":
|
if event == "issue":
|
||||||
webhooks = webhooks.filter(issue=True)
|
webhooks = webhooks.filter(issue=True)
|
||||||
|
|
||||||
if event == "module":
|
if event == "module" or event == "module_issue":
|
||||||
webhooks = webhooks.filter(module=True)
|
webhooks = webhooks.filter(module=True)
|
||||||
|
|
||||||
if event == "cycle":
|
if event == "cycle" or event == "cycle_issue":
|
||||||
webhooks = webhooks.filter(cycle=True)
|
webhooks = webhooks.filter(cycle=True)
|
||||||
|
|
||||||
if event == "issue-comment":
|
if event == "issue_comment":
|
||||||
webhooks = webhooks.filter(issue_comment=True)
|
webhooks = webhooks.filter(issue_comment=True)
|
||||||
|
|
||||||
for webhook in webhooks:
|
for webhook in webhooks:
|
||||||
|
Loading…
Reference in New Issue
Block a user