Use local time for channel ids

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-08 00:03:10 +02:00
parent d3d72e090c
commit a02697a3a7
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 3 additions and 1 deletions

View File

@ -27,6 +27,7 @@ from django.urls import reverse_lazy
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.decorators import method_decorator
from django.utils.timezone import localtime
from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import CreateView, DetailView, FormView, RedirectView, TemplateView, UpdateView, View
@ -1952,7 +1953,8 @@ class GSheetNotificationsView(View):
return HttpResponse(status=404)
tournament = await Tournament.objects.prefetch_related('participation_set', 'pools').aget(pk=kwargs['pk'])
expected_channel_id = sha1(f"{tournament.name}-{timezone.now().date()}-{request.site.domain}".encode()) \
now = localtime(timezone.now())
expected_channel_id = sha1(f"{tournament.name}-{now.date()}-{request.site.domain}".encode()) \
.hexdigest()
if request.headers['X-Goog-Channel-ID'] != expected_channel_id: