incoming webmentions: stop converting home pages to update activities

pass Protocol.receive the bare actor object, let it convert to update activity, like with posts etc
pull/968/head
Ryan Barrett 2024-04-23 06:50:55 -07:00
rodzic 0c41f0e081
commit d4a56127d9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 7 dodań i 26 usunięć

Wyświetl plik

@ -824,8 +824,8 @@ class Protocol:
to_cc = (as1.get_ids(inner_obj_as1, 'to')
+ as1.get_ids(inner_obj_as1, 'cc'))
content = inner_obj_as1.get('content', '').strip().lower()
logger.info(f'got DM to {to_cc}: {content}')
if len(to_cc) == 1:
logger.info(f'got DM to {to_cc}: {content}')
proto = Protocol.for_bridgy_subdomain(to_cc[0])
if proto:
if content in ('yes', 'ok'):

Wyświetl plik

@ -1632,6 +1632,10 @@ class WebTest(TestCase):
Follower.get_or_create(to=self.user, from_=self.make_user(
'http://d/dd', cls=ActivityPub, obj_as2={'inbox': 'https://inbox'}))
mf2 = copy.deepcopy(ACTOR_MF2)
mf2['properties']['name'] = 'original'
self.store_object(id='https://user.com/', mf2=mf2)
got = self.post('/queue/webmention', data={
'source': 'https://user.com/',
'target': 'https://fed.brid.gy/',
@ -1641,7 +1645,7 @@ class WebTest(TestCase):
self.req('https://user.com/'),
))
id = 'https://user.com/#update-2022-01-02T03:04:05+00:00'
id = 'https://user.com/#bridgy-fed-update-2022-01-02T03:04:05+00:00'
wrapped_id = f'http://localhost/r/{id}'
expected_as2 = {
'@context': 'https://www.w3.org/ns/activitystreams',
@ -1730,7 +1734,7 @@ class WebTest(TestCase):
self.req('https://user.com/'),
))
id = 'https://user.com/#update-2022-01-02T03:04:05+00:00'
id = 'https://user.com/#bridgy-fed-update-2022-01-02T03:04:05+00:00'
wrapped_id = f'http://localhost/r/{id}'
update_as2 = {
'@context': 'https://www.w3.org/ns/activitystreams',

23
web.py
Wyświetl plik

@ -839,29 +839,6 @@ def webmention_task():
else:
authors[0] = user.web_url()
# if source is home page, update Web user and send an actor Update to
# followers' instances
if user.key.id() == obj.key.id() or user.is_web_url(obj.key.id()):
logger.info(f'Converted to AS1: {obj.type}: {json_dumps(obj.as1, indent=2)}')
obj.put()
user.obj = obj
user.put()
logger.info('Wrapping in Update for home page user profile')
actor_as1 = {
**obj.as1,
'id': user.web_url(),
'updated': util.now().isoformat(),
}
id = common.host_url(f'{obj.key.id()}#update-{util.now().isoformat()}')
obj = Object(id=id, status='new', our_as1={
'objectType': 'activity',
'verb': 'update',
'id': id,
'actor': user.web_url(),
'object': actor_as1,
})
try:
return Web.receive(obj, authed_as=user.web_url())
except ValueError as e: