zilencer: Add last_request_datetime to RemoteRealm + RemoteZulipServer.

For the RemoteRealm case, we can only set this in endpoints where the
remote server sends us the realm_uuid. So we're missing that for the
endpoints:

- remotes/push/unregister and remotes/push/unregister/all
- remotes/push/test_notification

This should be added in a follow-up commit.
This commit is contained in:
Mateusz Mandera
2023-12-25 03:01:58 +01:00
committed by Tim Abbott
parent ee2baa30e0
commit cbfbdd7337
5 changed files with 75 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ from django.http import HttpRequest, HttpResponse
from django.urls import path
from django.urls.resolvers import URLPattern
from django.utils.crypto import constant_time_compare
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from typing_extensions import Concatenate, ParamSpec, override
@@ -120,6 +121,10 @@ def authenticated_remote_server_view(
raise UnauthorizedError(e.msg)
rate_limit_remote_server(request, remote_server, domain="api_by_remote_server")
remote_server.last_request_datetime = timezone_now()
remote_server.save(update_fields=["last_request_datetime"])
return view_func(request, remote_server, *args, **kwargs)
return _wrapped_view_func