kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
ee62334a93
commit
0a22643cef
|
@ -263,7 +263,7 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
||||||
user.existing = True
|
user.existing = True
|
||||||
|
|
||||||
# TODO: propagate more fields?
|
# TODO: propagate more fields?
|
||||||
for field in ['direct', 'enabled_protocols', 'obj', 'obj_key']:
|
for field in ['direct', 'obj', 'obj_key']:
|
||||||
old_val = getattr(user, field, None)
|
old_val = getattr(user, field, None)
|
||||||
new_val = kwargs.get(field)
|
new_val = kwargs.get(field)
|
||||||
if ((old_val is None and new_val is not None)
|
if ((old_val is None and new_val is not None)
|
||||||
|
@ -271,6 +271,10 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
||||||
setattr(user, field, new_val)
|
setattr(user, field, new_val)
|
||||||
user.put()
|
user.put()
|
||||||
|
|
||||||
|
if enabled_protocols := kwargs.get('enabled_protocols'):
|
||||||
|
user.enabled_protocols = (set(user.enabled_protocols)
|
||||||
|
| set(enabled_protocols))
|
||||||
|
|
||||||
if not propagate:
|
if not propagate:
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
|
@ -496,8 +500,6 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
||||||
def disable():
|
def disable():
|
||||||
user = self.key.get()
|
user = self.key.get()
|
||||||
remove(user.enabled_protocols, to_proto.LABEL)
|
remove(user.enabled_protocols, to_proto.LABEL)
|
||||||
# TODO: delete copy user
|
|
||||||
# https://github.com/snarfed/bridgy-fed/issues/783
|
|
||||||
user.put()
|
user.put()
|
||||||
|
|
||||||
disable()
|
disable()
|
||||||
|
|
|
@ -69,6 +69,13 @@ class UserTest(TestCase):
|
||||||
user.direct = True
|
user.direct = True
|
||||||
self.assert_entities_equal(same, user, ignore=['updated'])
|
self.assert_entities_equal(same, user, ignore=['updated'])
|
||||||
|
|
||||||
|
def test_get_or_create_existing_merge_enabled_protocols(self):
|
||||||
|
self.user.enabled_protocols = ['fake']
|
||||||
|
self.user.put()
|
||||||
|
|
||||||
|
user = Web.get_or_create('y.za', enabled_protocols=['other'])
|
||||||
|
self.assertCountEqual(['fake', 'other'], user.enabled_protocols)
|
||||||
|
|
||||||
@patch.object(Fake, 'DEFAULT_ENABLED_PROTOCOLS', ['other'])
|
@patch.object(Fake, 'DEFAULT_ENABLED_PROTOCOLS', ['other'])
|
||||||
def test_get_or_create_propagate_fake_other(self):
|
def test_get_or_create_propagate_fake_other(self):
|
||||||
user = Fake.get_or_create('fake:user', propagate=True)
|
user = Fake.get_or_create('fake:user', propagate=True)
|
||||||
|
|
Ładowanie…
Reference in New Issue