MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / post

Method post

apps/plugins/api_views.py:479–501  ·  view source on GitHub ↗
(self, request, key)

Source from the content-addressed store, hash-verified

477
478class PluginRunAPIView(PluginAuthMixin, APIView):
479 def post(self, request, key):
480 pm = PluginManager.get()
481 action = request.data.get("action")
482 params = request.data.get("params", {})
483 if not action:
484 return Response({"success": False, "error": "Missing 'action'"}, status=status.HTTP_400_BAD_REQUEST)
485
486 # Respect plugin enabled flag
487 try:
488 cfg = PluginConfig.objects.get(key=key)
489 if not cfg.enabled:
490 return Response({"success": False, "error": "Plugin is disabled"}, status=status.HTTP_403_FORBIDDEN)
491 except PluginConfig.DoesNotExist:
492 return Response({"success": False, "error": "Plugin not found"}, status=status.HTTP_404_NOT_FOUND)
493
494 try:
495 result = pm.run_action(key, action, params)
496 return Response({"success": True, "result": result})
497 except PermissionError as e:
498 return Response({"success": False, "error": str(e)}, status=status.HTTP_403_FORBIDDEN)
499 except Exception as e:
500 logger.exception("Plugin action failed")
501 return Response({"success": False, "error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
502
503
504class PluginEnabledAPIView(PluginAuthMixin, APIView):

Callers

nothing calls this directly

Calls 2

run_actionMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected