update profile button: make receive task instead of running it inline

pull/977/head
Ryan Barrett 2024-04-24 17:06:25 -07:00
rodzic 41b2aaa1a8
commit d6a10b4be0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 8 dodań i 14 usunięć

Wyświetl plik

@ -170,19 +170,16 @@ def update_profile(protocol, id):
try:
profile_obj = user.load(user.profile_id(), remote=True)
if profile_obj:
msg, status = user.receive(profile_obj)
else:
status = 400
msg = "couldn't fetch profile"
except (requests.RequestException, werkzeug.exceptions.HTTPException) as e:
status, msg = util.interpret_http_exception(e)
_, msg = util.interpret_http_exception(e)
flash(f"Couldn't update profile for {user.handle_or_id()}: {msg}")
if int(status) // 100 == 2:
if profile_obj:
common.create_task(queue='receive', obj=profile_obj.key.urlsafe(),
authed_as=id)
flash(f'Updating profile for {user.handle_or_id()}')
else:
flash(f"Couldn't update profile for {user.handle_or_id()}: {msg}")
flash(f"Couldn't update profile for {user.handle_or_id()}")
return redirect(user.user_page_path(), code=302)

Wyświetl plik

@ -1328,8 +1328,8 @@ class Protocol:
if obj.source_protocol:
logger.warning(f'Object {obj.key.id()} changed protocol from {obj.source_protocol} to {cls.LABEL} ?!')
obj.source_protocol = cls.LABEL
obj.put()
obj.put()
with objects_cache_lock:
objects_cache[id] = obj
return obj

Wyświetl plik

@ -184,10 +184,7 @@ class PagesTest(TestCase):
get_flashed_messages())
self.assertEqual(['fake:user'], Fake.fetched)
self.assert_object('fake:user', source_protocol='fake', our_as1={
**actor,
'updated': '2022-01-02T03:04:05+00:00',
})
self.assert_object('fake:user', source_protocol='fake', our_as1=actor)
def test_followers(self):
Follower.get_or_create(