kopia lustrzana https://gitlab.com/jaywink/federation
fix an embarrassing python programming error
rodzic
f7df1dff6e
commit
6b690f26fa
|
@ -1303,27 +1303,32 @@ def extract_and_validate(entity):
|
||||||
entity.extract_mentions()
|
entity.extract_mentions()
|
||||||
|
|
||||||
|
|
||||||
def extract_replies(replies, objs=[], visited=[]):
|
def extract_replies(replies):
|
||||||
items = getattr(replies, 'items', [])
|
objs = []
|
||||||
if items and not isinstance(items, list): items = [items]
|
visited = []
|
||||||
for obj in items:
|
|
||||||
if isinstance(obj, Note):
|
def walk_reply_collection(replies):
|
||||||
try:
|
items = getattr(replies, 'items', [])
|
||||||
obj = obj.to_base()
|
if items and not isinstance(items, list): items = [items]
|
||||||
extract_and_validate(obj)
|
for obj in items:
|
||||||
except ValueError as ex:
|
if isinstance(obj, Note):
|
||||||
logger.error("extract_replies - Failed to validate entity %s: %s", entity, ex)
|
try:
|
||||||
continue
|
obj = obj.to_base()
|
||||||
elif not isinstance(obj, str): continue
|
extract_and_validate(obj)
|
||||||
objs.append(obj)
|
except ValueError as ex:
|
||||||
if hasattr(replies, 'next_'):
|
logger.error("extract_replies - Failed to validate entity %s: %s", entity, ex)
|
||||||
if replies.next_ and (replies.id != replies.next_) and (replies.next_ not in visited):
|
continue
|
||||||
resp = retrieve_and_parse_document(replies.next_)
|
elif not isinstance(obj, str): continue
|
||||||
if resp:
|
objs.append(obj)
|
||||||
visited.append(replies.next_)
|
if getattr(replies, 'next_', None):
|
||||||
return objs + extract_replies(resp, objs, visited)
|
if (replies.id != replies.next_) and (replies.next_ not in visited):
|
||||||
return []
|
resp = retrieve_and_parse_document(replies.next_)
|
||||||
return []
|
if resp:
|
||||||
|
visited.append(replies.next_)
|
||||||
|
walk_reply_collection(resp)
|
||||||
|
|
||||||
|
walk_reply_collection(replies)
|
||||||
|
return objs
|
||||||
|
|
||||||
|
|
||||||
def element_to_objects(element: Union[Dict, Object]) -> List:
|
def element_to_objects(element: Union[Dict, Object]) -> List:
|
||||||
|
|
Ładowanie…
Reference in New Issue