diff options
Diffstat (limited to 'stator/views.py')
-rw-r--r-- | stator/views.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/stator/views.py b/stator/views.py index ef09b8e..9d2e154 100644 --- a/stator/views.py +++ b/stator/views.py @@ -1,8 +1,9 @@ -from django.http import HttpResponse +from django.conf import settings +from django.http import HttpResponse, HttpResponseForbidden from django.views import View +from stator.models import StatorModel from stator.runner import StatorRunner -from users.models import Follow class RequestRunner(View): @@ -12,6 +13,11 @@ class RequestRunner(View): """ async def get(self, request): - runner = StatorRunner([Follow]) + # Check the token, if supplied + if settings.STATOR_TOKEN: + if request.GET.get("token") != settings.STATOR_TOKEN: + return HttpResponseForbidden() + # Run on all models + runner = StatorRunner(StatorModel.subclasses) handled = await runner.run() return HttpResponse(f"Handled {handled}") |