mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
c0b4d7175f
commit
2ffe72bd12
|
@ -75,6 +75,51 @@ from webapp_timeline import htmlIndividualShare
|
||||||
from blocking import getCWlistVariable
|
from blocking import getCWlistVariable
|
||||||
|
|
||||||
|
|
||||||
|
def _validProfilePreviewPost(postJsonObject: {},
|
||||||
|
personUrl: str) -> (bool, {}):
|
||||||
|
"""Returns true if the given post should appear on a person/group profile
|
||||||
|
after searching for a handle
|
||||||
|
"""
|
||||||
|
isAnnouncedFeedItem = False
|
||||||
|
if isCreateInsideAnnounce(postJsonObject):
|
||||||
|
isAnnouncedFeedItem = True
|
||||||
|
postJsonObject = postJsonObject['object']
|
||||||
|
if not postJsonObject.get('type'):
|
||||||
|
return False, None
|
||||||
|
if postJsonObject['type'] == 'Create':
|
||||||
|
if not hasObjectDict(postJsonObject):
|
||||||
|
return False, None
|
||||||
|
if postJsonObject['type'] != 'Create' and \
|
||||||
|
postJsonObject['type'] != 'Announce':
|
||||||
|
if postJsonObject['type'] != 'Note' and \
|
||||||
|
postJsonObject['type'] != 'Page':
|
||||||
|
return False, None
|
||||||
|
if not postJsonObject.get('to'):
|
||||||
|
return False, None
|
||||||
|
if not postJsonObject.get('id'):
|
||||||
|
return False, None
|
||||||
|
# wrap in create
|
||||||
|
cc = []
|
||||||
|
if postJsonObject.get('cc'):
|
||||||
|
cc = postJsonObject['cc']
|
||||||
|
newPostJsonObject = {
|
||||||
|
'object': postJsonObject,
|
||||||
|
'to': postJsonObject['to'],
|
||||||
|
'cc': cc,
|
||||||
|
'id': postJsonObject['id'],
|
||||||
|
'actor': personUrl,
|
||||||
|
'type': 'Create'
|
||||||
|
}
|
||||||
|
postJsonObject = newPostJsonObject
|
||||||
|
if not postJsonObject.get('actor'):
|
||||||
|
return False, None
|
||||||
|
if not isAnnouncedFeedItem:
|
||||||
|
if postJsonObject['actor'] != personUrl and \
|
||||||
|
postJsonObject['object']['type'] != 'Page':
|
||||||
|
return False, None
|
||||||
|
return True, postJsonObject
|
||||||
|
|
||||||
|
|
||||||
def htmlProfileAfterSearch(cssCache: {},
|
def htmlProfileAfterSearch(cssCache: {},
|
||||||
recentPostsCache: {}, maxRecentPosts: int,
|
recentPostsCache: {}, maxRecentPosts: int,
|
||||||
translate: {},
|
translate: {},
|
||||||
|
@ -281,40 +326,9 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
if userFeed:
|
if userFeed:
|
||||||
i = 0
|
i = 0
|
||||||
for item in userFeed:
|
for item in userFeed:
|
||||||
isAnnouncedFeedItem = False
|
showItem, postJsonObject = \
|
||||||
if isCreateInsideAnnounce(item):
|
_validProfilePreviewPost(item, personUrl)
|
||||||
isAnnouncedFeedItem = True
|
if not showItem:
|
||||||
item = item['object']
|
|
||||||
if not item.get('type'):
|
|
||||||
continue
|
|
||||||
if item['type'] == 'Create':
|
|
||||||
if not hasObjectDict(item):
|
|
||||||
continue
|
|
||||||
if item['type'] != 'Create' and item['type'] != 'Announce':
|
|
||||||
if item['type'] != 'Note' and item['type'] != 'Page':
|
|
||||||
continue
|
|
||||||
if not item.get('to'):
|
|
||||||
continue
|
|
||||||
if not item.get('id'):
|
|
||||||
continue
|
|
||||||
# wrap in create
|
|
||||||
cc = []
|
|
||||||
if item.get('cc'):
|
|
||||||
cc = item['cc']
|
|
||||||
newItem = {
|
|
||||||
'object': item,
|
|
||||||
'to': item['to'],
|
|
||||||
'cc': cc,
|
|
||||||
'id': item['id'],
|
|
||||||
'actor': personUrl,
|
|
||||||
'type': 'Create'
|
|
||||||
}
|
|
||||||
item = newItem
|
|
||||||
if not item.get('actor'):
|
|
||||||
continue
|
|
||||||
if not isAnnouncedFeedItem:
|
|
||||||
if item['actor'] != personUrl and \
|
|
||||||
item['object']['type'] != 'Page':
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
profileStr += \
|
profileStr += \
|
||||||
|
@ -323,7 +337,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
translate, None, baseDir,
|
translate, None, baseDir,
|
||||||
session, cachedWebfingers, personCache,
|
session, cachedWebfingers, personCache,
|
||||||
nickname, domain, port,
|
nickname, domain, port,
|
||||||
item, avatarUrl, False, False,
|
postJsonObject, avatarUrl, False, False,
|
||||||
httpPrefix, projectVersion, 'inbox',
|
httpPrefix, projectVersion, 'inbox',
|
||||||
YTReplacementDomain,
|
YTReplacementDomain,
|
||||||
twitterReplacementDomain,
|
twitterReplacementDomain,
|
||||||
|
|
Loading…
Reference in New Issue