kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
374354a21f
commit
99bb564209
12
models.py
12
models.py
|
@ -97,12 +97,8 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
||||||
created = ndb.DateTimeProperty(auto_now_add=True)
|
created = ndb.DateTimeProperty(auto_now_add=True)
|
||||||
updated = ndb.DateTimeProperty(auto_now=True)
|
updated = ndb.DateTimeProperty(auto_now=True)
|
||||||
|
|
||||||
@ndb.ComputedProperty
|
|
||||||
def actor_as2(self):
|
|
||||||
return self.as2()
|
|
||||||
|
|
||||||
# OLD. some stored entities still have this; do not reuse.
|
# OLD. some stored entities still have this; do not reuse.
|
||||||
old_actor_as2 = JsonProperty(name='actor_as2')
|
# actor_as2 = JsonProperty()
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
@ -203,8 +199,10 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
||||||
u._obj = keys_to_objs.get(u.obj_key)
|
u._obj = keys_to_objs.get(u.obj_key)
|
||||||
|
|
||||||
def as2(self):
|
def as2(self):
|
||||||
return (as2.from_as1(self.obj.as1) if self.obj and self.obj.as1
|
if self.obj and self.obj.as1:
|
||||||
else self.old_actor_as2)
|
return self.obj.as2 or as2.from_as1(self.obj.as1)
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
||||||
@ndb.ComputedProperty
|
@ndb.ComputedProperty
|
||||||
def readable_id(self):
|
def readable_id(self):
|
||||||
|
|
|
@ -313,8 +313,8 @@ class TestCase(unittest.TestCase, testutil.Asserts):
|
||||||
self.assert_equals(obj_as2, got.as2())
|
self.assert_equals(obj_as2, got.as2())
|
||||||
|
|
||||||
# generated, computed, etc
|
# generated, computed, etc
|
||||||
ignore = ['created', 'mod', 'obj_key', 'old_actor_as2', 'p256_key',
|
ignore = ['created', 'mod', 'obj_key', 'p256_key', 'private_exponent',
|
||||||
'private_exponent', 'public_exponent', 'readable_id', 'updated']
|
'public_exponent', 'readable_id', 'updated']
|
||||||
for prop in ignore:
|
for prop in ignore:
|
||||||
assert prop not in props
|
assert prop not in props
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue