Stop a channel and release all associated resources using PubSub events
(request, channel_id)
| 851 | @api_view(["POST", "DELETE"]) |
| 852 | @permission_classes([IsAdmin]) |
| 853 | def stop_channel(request, channel_id): |
| 854 | """Stop a channel and release all associated resources using PubSub events""" |
| 855 | try: |
| 856 | logger.info(f"Request to stop channel {channel_id} received") |
| 857 | |
| 858 | # Use the service layer instead of direct implementation |
| 859 | result = ChannelService.stop_channel(channel_id) |
| 860 | |
| 861 | if result.get("status") == "error": |
| 862 | return JsonResponse( |
| 863 | {"error": result.get("message", "Unknown error")}, status=404 |
| 864 | ) |
| 865 | |
| 866 | return JsonResponse( |
| 867 | { |
| 868 | "message": "Channel stop request sent", |
| 869 | "channel_id": channel_id, |
| 870 | "previous_state": result.get("previous_state"), |
| 871 | } |
| 872 | ) |
| 873 | |
| 874 | except Exception as e: |
| 875 | logger.error(f"Failed to stop channel: {e}", exc_info=True) |
| 876 | return JsonResponse({"error": str(e)}, status=500) |
| 877 | |
| 878 | |
| 879 | @csrf_exempt |
nothing calls this directly
no test coverage detected