mirror of https://gitlab.com/bashrc2/epicyon
Show replies
parent
a2c95ba9af
commit
5f24d6cda4
28
daemon.py
28
daemon.py
|
@ -465,28 +465,24 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"""
|
"""
|
||||||
if postJsonObject.get('likes'):
|
if postJsonObject.get('likes'):
|
||||||
postJsonObject['likes'] = {'items': []}
|
postJsonObject['likes'] = {'items': []}
|
||||||
if postJsonObject.get('shares'):
|
|
||||||
postJsonObject['shares'] = {}
|
removeCollections = (
|
||||||
if postJsonObject.get('replies'):
|
'shares', 'replies', 'bookmarks', 'ignores'
|
||||||
postJsonObject['replies'] = {}
|
)
|
||||||
if postJsonObject.get('bookmarks'):
|
for removeName in removeCollections:
|
||||||
postJsonObject['bookmarks'] = {}
|
if postJsonObject.get(removeName):
|
||||||
if postJsonObject.get('ignores'):
|
postJsonObject[removeName] = {}
|
||||||
postJsonObject['ignores'] = {}
|
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
return
|
return
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
return
|
return
|
||||||
if postJsonObject['object'].get('likes'):
|
if postJsonObject['object'].get('likes'):
|
||||||
postJsonObject['object']['likes'] = {'items': []}
|
postJsonObject['object']['likes'] = {'items': []}
|
||||||
if postJsonObject['object'].get('shares'):
|
|
||||||
postJsonObject['object']['shares'] = {}
|
for removeName in removeCollections:
|
||||||
if postJsonObject['object'].get('replies'):
|
if postJsonObject['object'].get(removeName):
|
||||||
postJsonObject['object']['replies'] = {}
|
postJsonObject['object'][removeName] = {}
|
||||||
if postJsonObject['object'].get('bookmarks'):
|
|
||||||
postJsonObject['object']['bookmarks'] = {}
|
|
||||||
if postJsonObject['object'].get('ignores'):
|
|
||||||
postJsonObject['object']['ignores'] = {}
|
|
||||||
|
|
||||||
def _requestHTTP(self) -> bool:
|
def _requestHTTP(self) -> bool:
|
||||||
"""Should a http response be given?
|
"""Should a http response be given?
|
||||||
|
|
|
@ -217,6 +217,10 @@ def _newDesktopNotifications(actor: str, inboxJson: {},
|
||||||
for postJsonObject in inboxJson['orderedItems']:
|
for postJsonObject in inboxJson['orderedItems']:
|
||||||
if not postJsonObject.get('id'):
|
if not postJsonObject.get('id'):
|
||||||
continue
|
continue
|
||||||
|
if not postJsonObject.get('type'):
|
||||||
|
continue
|
||||||
|
if postJsonObject['type'] == 'Announce':
|
||||||
|
continue
|
||||||
if not _postIsToYou(actor, postJsonObject):
|
if not _postIsToYou(actor, postJsonObject):
|
||||||
continue
|
continue
|
||||||
if isDM(postJsonObject):
|
if isDM(postJsonObject):
|
||||||
|
@ -604,6 +608,32 @@ def _showLikesOnPost(postJsonObject: {}, maxLikes: int) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def _showRepliesOnPost(postJsonObject: {}, maxReplies: int) -> None:
|
||||||
|
"""Shows the replies on a post
|
||||||
|
"""
|
||||||
|
if not postJsonObject.get('object'):
|
||||||
|
return
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
return
|
||||||
|
if not postJsonObject['object'].get('replies'):
|
||||||
|
return
|
||||||
|
if not isinstance(postJsonObject['object']['replies'], dict):
|
||||||
|
return
|
||||||
|
if not postJsonObject['object']['replies'].get('items'):
|
||||||
|
return
|
||||||
|
if not isinstance(postJsonObject['object']['replies']['items'], list):
|
||||||
|
return
|
||||||
|
print('')
|
||||||
|
ctr = 0
|
||||||
|
print('Test 4638653 ' + str(postJsonObject['object']['replies']['items']))
|
||||||
|
for item in postJsonObject['object']['replies']['items']:
|
||||||
|
print('Test 768235 ' + str(item))
|
||||||
|
print(' ↰ ' + str(item['url']))
|
||||||
|
ctr += 1
|
||||||
|
if ctr >= maxReplies:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def _readLocalBoxPost(session, nickname: str, domain: str,
|
def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
httpPrefix: str, baseDir: str, boxName: str,
|
httpPrefix: str, baseDir: str, boxName: str,
|
||||||
pageNumber: int, index: int, boxJson: {},
|
pageNumber: int, index: int, boxJson: {},
|
||||||
|
@ -705,6 +735,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
systemLanguage, espeak, nameStr, gender)
|
systemLanguage, espeak, nameStr, gender)
|
||||||
|
|
||||||
_showLikesOnPost(postJsonObject, 10)
|
_showLikesOnPost(postJsonObject, 10)
|
||||||
|
_showRepliesOnPost(postJsonObject, 10)
|
||||||
|
|
||||||
# if the post is addressed to you then mark it as read
|
# if the post is addressed to you then mark it as read
|
||||||
if _postIsToYou(yourActor, postJsonObject):
|
if _postIsToYou(yourActor, postJsonObject):
|
||||||
|
@ -902,9 +933,6 @@ def _desktopShowBox(yourActor: str, boxName: str, boxJson: {},
|
||||||
indent + str(posStr) + ' | ' + name + ' | ' + \
|
indent + str(posStr) + ' | ' + name + ' | ' + \
|
||||||
published + ' | ' + \
|
published + ' | ' + \
|
||||||
_padToWidth(announcedHandle, contentWidth)
|
_padToWidth(announcedHandle, contentWidth)
|
||||||
if boxName == 'inbox' and \
|
|
||||||
_postIsToYou(yourActor, postJsonObject):
|
|
||||||
lineStr = '\33[7m' + lineStr + '\33[0m'
|
|
||||||
print(lineStr)
|
print(lineStr)
|
||||||
ctr += 1
|
ctr += 1
|
||||||
continue
|
continue
|
||||||
|
@ -935,6 +963,14 @@ def _desktopShowBox(yourActor: str, boxName: str, boxJson: {},
|
||||||
spaceAdded = True
|
spaceAdded = True
|
||||||
name += ' '
|
name += ' '
|
||||||
name += '↲'
|
name += '↲'
|
||||||
|
if postJsonObject['object'].get('replies'):
|
||||||
|
repliesList = postJsonObject['object']['replies']
|
||||||
|
if repliesList.get('items'):
|
||||||
|
items = repliesList['items']
|
||||||
|
for i in range(int(items)):
|
||||||
|
name += '↰'
|
||||||
|
if i > 10:
|
||||||
|
break
|
||||||
likesCount = noOfLikes(postJsonObject)
|
likesCount = noOfLikes(postJsonObject)
|
||||||
if likesCount > 10:
|
if likesCount > 10:
|
||||||
likesCount = 10
|
likesCount = 10
|
||||||
|
|
16
posts.py
16
posts.py
|
@ -3266,15 +3266,13 @@ def _createBoxIndexed(recentPostsCache: {},
|
||||||
if not isPublicPost(p):
|
if not isPublicPost(p):
|
||||||
continue
|
continue
|
||||||
if p['object'].get('likes'):
|
if p['object'].get('likes'):
|
||||||
p['likes'] = {'items': []}
|
p['object']['likes'] = {'items': []}
|
||||||
if p['object'].get('replies'):
|
removeCollections = {
|
||||||
p['replies'] = {}
|
'replies', 'shares', 'bookmarks', 'ignores'
|
||||||
if p['object'].get('shares'):
|
}
|
||||||
p['shares'] = {}
|
for removeName in removeCollections:
|
||||||
if p['object'].get('bookmarks'):
|
if p['object'].get(removeName):
|
||||||
p['bookmarks'] = {}
|
p['object'][removeName] = {}
|
||||||
if p['object'].get('ignores'):
|
|
||||||
p['ignores'] = {}
|
|
||||||
|
|
||||||
boxItems['orderedItems'].append(p)
|
boxItems['orderedItems'].append(p)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue