Allow question updates in timeline

main
Bob Mottram 2019-11-25 10:10:59 +00:00
parent 168bcf84f9
commit c6d008b28a
2 changed files with 18 additions and 12 deletions

View File

@ -2052,7 +2052,7 @@ def addPostStringToTimeline(postStr: str,boxname: str,postsInBox: [],boxActor: s
"""
# must be a "Note" or "Announce" type
if '"Note"' in postStr or '"Announce"' in postStr or \
('"Question"' in postStr and '"Create"' in postStr):
('"Question"' in postStr and ('"Create"' in postStr or '"Update"' in postStr)):
if boxname=='dm':
if '#Public' in postStr or '/followers' in postStr:
@ -2171,16 +2171,16 @@ def createBoxIndexed(recentPostsCache: {}, \
postUrl=postFilename.replace('\n','').replace('.json','').strip()
postAdded=False
# is the post cached in memory?
if recentPostsCache.get('index'):
if postUrl in recentPostsCache['index']:
if recentPostsCache['json'].get(postUrl):
addPostStringToTimeline(recentPostsCache['json'][postUrl], \
boxname,postsInBox,boxActor)
#print('Json post added to timeline from cache: '+postUrl)
postAdded=True
if not postAdded:
# get the full path of the post
# read the post from file
fullPostFilename= \
locatePost(baseDir,nickname,domain,postUrl,False)
if fullPostFilename:

View File

@ -2373,14 +2373,20 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
def isQuestion(postObjectJson: {}) -> bool:
""" is the given post a question?
"""
if postObjectJson['type']=='Create':
if isinstance(postObjectJson['object'], dict):
if postObjectJson['object'].get('type'):
if postObjectJson['object']['type']=='Question':
if postObjectJson['object'].get('oneOf'):
if isinstance(postObjectJson['object']['oneOf'], list):
return True
return False
if postObjectJson['type']!='Create' and \
postObjectJson['type']!='Update':
return False
if not isinstance(postObjectJson['object'], dict):
return False
if not postObjectJson['object'].get('type'):
return False
if postObjectJson['object']['type']!='Question':
return False
if not postObjectJson['object'].get('oneOf'):
return False
if not isinstance(postObjectJson['object']['oneOf'], list):
return False
return True
def htmlTimeline(recentPostsCache: {},maxRecentPosts: int,
translate: {},pageNumber: int, \
@ -2592,7 +2598,7 @@ def htmlTimeline(recentPostsCache: {},maxRecentPosts: int,
tlStr+='<br>'
tlStr+='<div class="galleryContainer">\n'
for item in timelineJson['orderedItems']:
if item['type']=='Create' or item['type']=='Announce':
if item['type']=='Create' or item['type']=='Announce' or item['type']=='Update':
# is the actor who sent this post snoozed?
if isPersonSnoozed(baseDir,nickname,domain,item['actor']):
continue