mirror of https://gitlab.com/bashrc2/epicyon
Parsing lemmy-style public feeds
parent
cd0224e788
commit
b1ce2ded40
32
posts.py
32
posts.py
|
@ -415,6 +415,11 @@ def getPersonBox(signingPrivateKeyPem: str,
|
||||||
def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool:
|
def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool:
|
||||||
"""Is the given post a public feed post?
|
"""Is the given post a public feed post?
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
if debug:
|
||||||
|
print('item object is not a dict')
|
||||||
|
pprint(item)
|
||||||
|
return False
|
||||||
if not item.get('id'):
|
if not item.get('id'):
|
||||||
if debug:
|
if debug:
|
||||||
print('No id')
|
print('No id')
|
||||||
|
@ -427,11 +432,6 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool:
|
||||||
if debug:
|
if debug:
|
||||||
print('Not Create type')
|
print('Not Create type')
|
||||||
return False
|
return False
|
||||||
if not isinstance(item, dict):
|
|
||||||
if debug:
|
|
||||||
print('item object is not a dict')
|
|
||||||
pprint(item)
|
|
||||||
return False
|
|
||||||
if item.get('object'):
|
if item.get('object'):
|
||||||
if isinstance(item['object'], dict):
|
if isinstance(item['object'], dict):
|
||||||
if not item['object'].get('published'):
|
if not item['object'].get('published'):
|
||||||
|
@ -471,6 +471,25 @@ def _isPublicFeedPost(item: {}, personPosts: {}, debug: bool) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _isCreateInsideAnnounce(item: {}) -> bool:
|
||||||
|
""" is this a Create inside of an Announce?
|
||||||
|
eg. lemmy feed item
|
||||||
|
"""
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
return False
|
||||||
|
if item['type'] != 'Announce':
|
||||||
|
return False
|
||||||
|
if not item.get('object'):
|
||||||
|
return False
|
||||||
|
if not isinstance(item['object'], dict):
|
||||||
|
return False
|
||||||
|
if not item['object'].get('type'):
|
||||||
|
return False
|
||||||
|
if item['object']['type'] != 'Create':
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _getPosts(session, outboxUrl: str, maxPosts: int,
|
def _getPosts(session, outboxUrl: str, maxPosts: int,
|
||||||
maxMentions: int,
|
maxMentions: int,
|
||||||
maxEmoji: int, maxAttachments: int,
|
maxEmoji: int, maxAttachments: int,
|
||||||
|
@ -527,6 +546,9 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for item in userFeed:
|
for item in userFeed:
|
||||||
|
if _isCreateInsideAnnounce(item):
|
||||||
|
item = item['object']
|
||||||
|
|
||||||
if not _isPublicFeedPost(item, personPosts, debug):
|
if not _isPublicFeedPost(item, personPosts, debug):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue