mirror of https://gitlab.com/bashrc2/epicyon
Fixing posts option
parent
b265dbe0b8
commit
9b7add2f24
60
posts.py
60
posts.py
|
@ -184,7 +184,7 @@ def getUserUrl(wfRequest: {}, sourceId: int = 0, debug: bool = False) -> str:
|
|||
|
||||
def parseUserFeed(session, feedUrl: str, asHeader: {},
|
||||
projectVersion: str, httpPrefix: str,
|
||||
domain: str, debug: bool, depth: int = 0) -> {}:
|
||||
domain: str, debug: bool, depth: int = 0) -> []:
|
||||
if depth > 10:
|
||||
if debug:
|
||||
print('Maximum search depth reached')
|
||||
|
@ -205,8 +205,9 @@ def parseUserFeed(session, feedUrl: str, asHeader: {},
|
|||
pprint(feedJson)
|
||||
|
||||
if 'orderedItems' in feedJson:
|
||||
for item in feedJson['orderedItems']:
|
||||
yield item
|
||||
#for item in feedJson['orderedItems']:
|
||||
# yield item
|
||||
return feedJson['orderedItems']
|
||||
|
||||
nextUrl = None
|
||||
if 'first' in feedJson:
|
||||
|
@ -225,13 +226,16 @@ def parseUserFeed(session, feedUrl: str, asHeader: {},
|
|||
projectVersion, httpPrefix,
|
||||
domain, debug, depth + 1)
|
||||
if userFeed:
|
||||
for item in userFeed:
|
||||
yield item
|
||||
#for item in userFeed:
|
||||
# yield item
|
||||
return userFeed
|
||||
elif isinstance(nextUrl, dict):
|
||||
userFeed = nextUrl
|
||||
if userFeed.get('orderedItems'):
|
||||
for item in userFeed['orderedItems']:
|
||||
yield item
|
||||
#for item in userFeed['orderedItems']:
|
||||
# yield item
|
||||
return userFeed['orderedItems']
|
||||
return None
|
||||
|
||||
|
||||
def _getPersonBoxActor(session, baseDir: str, actor: str,
|
||||
|
@ -411,21 +415,34 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
|
|||
if debug:
|
||||
print('No type')
|
||||
continue
|
||||
if item['type'] != 'Create':
|
||||
if item['type'] != 'Create' and item['type'] != 'Announce':
|
||||
if debug:
|
||||
print('Not Create type')
|
||||
continue
|
||||
if not hasObjectDict(item):
|
||||
if not isinstance(item, dict):
|
||||
if debug:
|
||||
print('item object is not a dict')
|
||||
pprint(item)
|
||||
continue
|
||||
if item.get('object'):
|
||||
if isinstance(item['object'], dict):
|
||||
if not item['object'].get('published'):
|
||||
if debug:
|
||||
print('No published attribute')
|
||||
continue
|
||||
elif isinstance(item['object'], str):
|
||||
if not item.get('published'):
|
||||
if debug:
|
||||
print('No published attribute')
|
||||
continue
|
||||
else:
|
||||
if debug:
|
||||
print('object is not a dict or string')
|
||||
continue
|
||||
if not personPosts.get(item['id']):
|
||||
# check that this is a public post
|
||||
# #Public should appear in the "to" list
|
||||
if isinstance(item['object'], dict):
|
||||
if item['object'].get('to'):
|
||||
isPublic = False
|
||||
for recipient in item['object']['to']:
|
||||
|
@ -434,12 +451,26 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
|
|||
break
|
||||
if not isPublic:
|
||||
continue
|
||||
elif isinstance(item['object'], str):
|
||||
if item.get('to'):
|
||||
isPublic = False
|
||||
for recipient in item['to']:
|
||||
if recipient.endswith('#Public'):
|
||||
isPublic = True
|
||||
break
|
||||
if not isPublic:
|
||||
continue
|
||||
|
||||
content = getBaseContentFromPost(item, systemLanguage)
|
||||
content = content.replace(''', "'")
|
||||
|
||||
mentions = []
|
||||
emoji = {}
|
||||
summary = ''
|
||||
inReplyTo = ''
|
||||
attachment = []
|
||||
sensitive = False
|
||||
if isinstance(item['object'], dict):
|
||||
if item['object'].get('tag'):
|
||||
for tagItem in item['object']['tag']:
|
||||
tagType = tagItem['type'].lower()
|
||||
|
@ -469,12 +500,10 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
|
|||
print('max emojis reached')
|
||||
continue
|
||||
|
||||
summary = ''
|
||||
if item['object'].get('summary'):
|
||||
if item['object']['summary']:
|
||||
summary = item['object']['summary']
|
||||
|
||||
inReplyTo = ''
|
||||
if item['object'].get('inReplyTo'):
|
||||
if item['object']['inReplyTo']:
|
||||
if isinstance(item['object']['inReplyTo'], str):
|
||||
|
@ -487,15 +516,6 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
|
|||
continue
|
||||
inReplyTo = item['object']['inReplyTo']
|
||||
|
||||
conversation = ''
|
||||
if item['object'].get('conversation'):
|
||||
if item['object']['conversation']:
|
||||
# no conversations originated in non-permitted domains
|
||||
if urlPermitted(item['object']['conversation'],
|
||||
federationList):
|
||||
conversation = item['object']['conversation']
|
||||
|
||||
attachment = []
|
||||
if item['object'].get('attachment'):
|
||||
if item['object']['attachment']:
|
||||
for attach in item['object']['attachment']:
|
||||
|
|
Loading…
Reference in New Issue