Ryan Barrett 2025-01-29 14:11:10 -08:00
rodzic 7d6b30f67e
commit ece5592421
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 20 dodań i 2 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
"""Base protocol class and common code."""
import copy
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
import logging
import os
import re
@ -965,7 +965,10 @@ class Protocol:
if obj.type == 'post':
if published := inner_obj_as1.get('published'):
try:
age = util.now() - util.parse_iso8601(published)
published_dt = util.parse_iso8601(published)
if not published_dt.tzinfo:
published_dt = published_dt.replace(tzinfo=timezone.utc)
age = util.now() - published_dt
if age > CREATE_MAX_AGE:
error(f'Ignoring, too old, {age} is over {CREATE_MAX_AGE}',
status=204)

Wyświetl plik

@ -3050,6 +3050,21 @@ class ProtocolReceiveTest(TestCase):
self.assertEqual([], Fake.sent)
self.assertEqual([], OtherFake.sent)
def test_too_old_published_without_timezone(self):
Follower.get_or_create(to=self.user, from_=self.alice)
with self.assertRaises(NoContent):
Fake.receive_as1({
'id': 'fake:post',
'objectType': 'note',
'author': 'fake:user',
'published': '2021-12-14T03:04:05', # NOW - 2w
})
self.assertIsNone(Object.get_by_id('fake:post'))
self.assertEqual([], Fake.sent)
self.assertEqual([], OtherFake.sent)
def test_receive_activity_lease(self):
Follower.get_or_create(to=self.user, from_=self.alice)