add Web.last_webmention_in property

for #550
pull/741/head
Ryan Barrett 2023-12-03 21:46:31 -08:00
rodzic c54df36164
commit 637128a05c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -564,6 +564,8 @@ class WebTest(TestCase):
self.assert_task(mock_create_task, 'webmention', '/queue/webmention',
**params)
self.assertEqual(NOW, self.user.key.get().last_webmention_in)
def test_no_user(self, mock_get, mock_post):
orig_count = Object.query().count()

9
web.py
Wyświetl plik

@ -1,5 +1,5 @@
"""Webmention protocol with microformats2 in HTML, aka the IndieWeb stack."""
import datetime
from datetime import timedelta, timezone
import difflib
import logging
import re
@ -89,6 +89,7 @@ class Web(User, Protocol):
has_redirects = ndb.BooleanProperty()
redirects_error = ndb.TextProperty()
has_hcard = ndb.BooleanProperty()
last_webmention_in = ndb.DateTimeProperty(tzinfo=timezone.utc)
# Originally, BF served Web users' AP actor ids on fed.brid.gy, eg
# https://fed.brid.gy/snarfed.org . When we started adding new protocols, we
@ -510,7 +511,7 @@ class Web(User, Protocol):
@app.get('/web-site')
@flask_util.cached(cache, datetime.timedelta(days=1))
@flask_util.cached(cache, timedelta(days=1))
def enter_web_site():
return render_template('enter_web_site.html')
@ -559,6 +560,10 @@ def webmention_external():
if not user:
error(f'No user found for domain {domain}')
if request.path == '/webmention': # exclude interactive
user.last_webmention_in = util.now()
user.put()
return common.create_task('webmention', **request.form)