|
@@ -5,10 +5,10 @@ from django.contrib.contenttypes.models import ContentType
|
|
|
from django.utils import timezone
|
|
from django.utils import timezone
|
|
|
from django_rq import get_queue
|
|
from django_rq import get_queue
|
|
|
|
|
|
|
|
-from extras.models import Webhook
|
|
|
|
|
from utilities.api import get_serializer_for_model
|
|
from utilities.api import get_serializer_for_model
|
|
|
from .choices import *
|
|
from .choices import *
|
|
|
-from .utils import FeatureQuery
|
|
|
|
|
|
|
+from .models import Webhook
|
|
|
|
|
+from .registry import registry
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_signature(request_body, secret):
|
|
def generate_signature(request_body, secret):
|
|
@@ -28,13 +28,14 @@ def enqueue_webhooks(instance, user, request_id, action):
|
|
|
Find Webhook(s) assigned to this instance + action and enqueue them
|
|
Find Webhook(s) assigned to this instance + action and enqueue them
|
|
|
to be processed
|
|
to be processed
|
|
|
"""
|
|
"""
|
|
|
- obj_type = ContentType.objects.get_for_model(instance.__class__)
|
|
|
|
|
-
|
|
|
|
|
- webhook_models = ContentType.objects.filter(FeatureQuery('webhooks').get_query())
|
|
|
|
|
- if obj_type not in webhook_models:
|
|
|
|
|
|
|
+ # Determine whether this type of object supports webhooks
|
|
|
|
|
+ app_label = instance._meta.app_label
|
|
|
|
|
+ model_name = instance._meta.model_name
|
|
|
|
|
+ if model_name not in registry['model_features']['webhooks'].get(app_label, []):
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
# Retrieve any applicable Webhooks
|
|
# Retrieve any applicable Webhooks
|
|
|
|
|
+ obj_type = ContentType.objects.get_for_model(instance)
|
|
|
action_flag = {
|
|
action_flag = {
|
|
|
ObjectChangeActionChoices.ACTION_CREATE: 'type_create',
|
|
ObjectChangeActionChoices.ACTION_CREATE: 'type_create',
|
|
|
ObjectChangeActionChoices.ACTION_UPDATE: 'type_update',
|
|
ObjectChangeActionChoices.ACTION_UPDATE: 'type_update',
|