kopia lustrzana https://github.com/snarfed/bridgy-fed
update profile button: make receive task instead of running it inline
rodzic
41b2aaa1a8
commit
d6a10b4be0
15
pages.py
15
pages.py
|
@ -170,19 +170,16 @@ def update_profile(protocol, id):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
profile_obj = user.load(user.profile_id(), remote=True)
|
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:
|
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()}')
|
flash(f'Updating profile for {user.handle_or_id()}')
|
||||||
else:
|
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)
|
return redirect(user.user_page_path(), code=302)
|
||||||
|
|
||||||
|
|
|
@ -1328,8 +1328,8 @@ class Protocol:
|
||||||
if obj.source_protocol:
|
if obj.source_protocol:
|
||||||
logger.warning(f'Object {obj.key.id()} changed protocol from {obj.source_protocol} to {cls.LABEL} ?!')
|
logger.warning(f'Object {obj.key.id()} changed protocol from {obj.source_protocol} to {cls.LABEL} ?!')
|
||||||
obj.source_protocol = cls.LABEL
|
obj.source_protocol = cls.LABEL
|
||||||
obj.put()
|
|
||||||
|
|
||||||
|
obj.put()
|
||||||
with objects_cache_lock:
|
with objects_cache_lock:
|
||||||
objects_cache[id] = obj
|
objects_cache[id] = obj
|
||||||
return obj
|
return obj
|
||||||
|
|
|
@ -184,10 +184,7 @@ class PagesTest(TestCase):
|
||||||
get_flashed_messages())
|
get_flashed_messages())
|
||||||
|
|
||||||
self.assertEqual(['fake:user'], Fake.fetched)
|
self.assertEqual(['fake:user'], Fake.fetched)
|
||||||
self.assert_object('fake:user', source_protocol='fake', our_as1={
|
self.assert_object('fake:user', source_protocol='fake', our_as1=actor)
|
||||||
**actor,
|
|
||||||
'updated': '2022-01-02T03:04:05+00:00',
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_followers(self):
|
def test_followers(self):
|
||||||
Follower.get_or_create(
|
Follower.get_or_create(
|
||||||
|
|
Ładowanie…
Reference in New Issue