From b7344566effad7409df8e394a27a908590d44807 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 6 Apr 2024 22:04:55 +0200 Subject: [PATCH] Only accept GDrive notifications if the content was updated Signed-off-by: Emmy D'Anello --- participation/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/participation/views.py b/participation/views.py index c084096..ff789ee 100644 --- a/participation/views.py +++ b/participation/views.py @@ -1893,6 +1893,10 @@ class GSheetNotificationsView(View): if request.headers['X-Goog-Channel-ID'] != expected_channel_id: raise ValueError(f"Invalid channel ID: {request.headers['X-Goog-Channel-ID']}") + if request.headers['X-Goog-Resource-State'] != 'update' \ + or 'content' not in request.headers['X-Goog-Changed'].split(','): + return HttpResponse(status=204) + # Run the parsing in dedicated executors since it takes time executor = ThreadPoolExecutor() async for pool in tournament.pools.prefetch_related('participations', 'passages__notes', 'juries').all():