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'):
|
||||
postJsonObject['likes'] = {'items': []}
|
||||
if postJsonObject.get('shares'):
|
||||
postJsonObject['shares'] = {}
|
||||
if postJsonObject.get('replies'):
|
||||
postJsonObject['replies'] = {}
|
||||
if postJsonObject.get('bookmarks'):
|
||||
postJsonObject['bookmarks'] = {}
|
||||
if postJsonObject.get('ignores'):
|
||||
postJsonObject['ignores'] = {}
|
||||
|
||||
removeCollections = (
|
||||
'shares', 'replies', 'bookmarks', 'ignores'
|
||||
)
|
||||
for removeName in removeCollections:
|
||||
if postJsonObject.get(removeName):
|
||||
postJsonObject[removeName] = {}
|
||||
|
||||
if not postJsonObject.get('object'):
|
||||
return
|
||||
if not isinstance(postJsonObject['object'], dict):
|
||||
return
|
||||
if postJsonObject['object'].get('likes'):
|
||||
postJsonObject['object']['likes'] = {'items': []}
|
||||
if postJsonObject['object'].get('shares'):
|
||||
postJsonObject['object']['shares'] = {}
|
||||
if postJsonObject['object'].get('replies'):
|
||||
postJsonObject['object']['replies'] = {}
|
||||
if postJsonObject['object'].get('bookmarks'):
|
||||
postJsonObject['object']['bookmarks'] = {}
|
||||
if postJsonObject['object'].get('ignores'):
|
||||
postJsonObject['object']['ignores'] = {}
|
||||
|
||||
for removeName in removeCollections:
|
||||
if postJsonObject['object'].get(removeName):
|
||||
postJsonObject['object'][removeName] = {}
|
||||
|
||||
def _requestHTTP(self) -> bool:
|
||||
"""Should a http response be given?
|
||||
|
|
|
@ -217,6 +217,10 @@ def _newDesktopNotifications(actor: str, inboxJson: {},
|
|||
for postJsonObject in inboxJson['orderedItems']:
|
||||
if not postJsonObject.get('id'):
|
||||
continue
|
||||
if not postJsonObject.get('type'):
|
||||
continue
|
||||
if postJsonObject['type'] == 'Announce':
|
||||
continue
|
||||
if not _postIsToYou(actor, postJsonObject):
|
||||
continue
|
||||
if isDM(postJsonObject):
|
||||
|
@ -604,6 +608,32 @@ def _showLikesOnPost(postJsonObject: {}, maxLikes: int) -> None:
|
|||
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,
|
||||
httpPrefix: str, baseDir: str, boxName: str,
|
||||
pageNumber: int, index: int, boxJson: {},
|
||||
|
@ -705,6 +735,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
|||
systemLanguage, espeak, nameStr, gender)
|
||||
|
||||
_showLikesOnPost(postJsonObject, 10)
|
||||
_showRepliesOnPost(postJsonObject, 10)
|
||||
|
||||
# if the post is addressed to you then mark it as read
|
||||
if _postIsToYou(yourActor, postJsonObject):
|
||||
|
@ -902,9 +933,6 @@ def _desktopShowBox(yourActor: str, boxName: str, boxJson: {},
|
|||
indent + str(posStr) + ' | ' + name + ' | ' + \
|
||||
published + ' | ' + \
|
||||
_padToWidth(announcedHandle, contentWidth)
|
||||
if boxName == 'inbox' and \
|
||||
_postIsToYou(yourActor, postJsonObject):
|
||||
lineStr = '\33[7m' + lineStr + '\33[0m'
|
||||
print(lineStr)
|
||||
ctr += 1
|
||||
continue
|
||||
|
@ -935,6 +963,14 @@ def _desktopShowBox(yourActor: str, boxName: str, boxJson: {},
|
|||
spaceAdded = True
|
||||
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)
|
||||
if likesCount > 10:
|
||||
likesCount = 10
|
||||
|
|
22
posts.py
22
posts.py
|
@ -2885,15 +2885,15 @@ def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
|||
boxUrl = httpPrefix+'://'+domain+'/users/'+nickname+'/'+boxname
|
||||
boxHeader = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'first': boxUrl+'?page=true',
|
||||
'first': boxUrl + '?page=true',
|
||||
'id': boxUrl,
|
||||
'last': boxUrl+'?page=true',
|
||||
'last': boxUrl + '?page=true',
|
||||
'totalItems': 0,
|
||||
'type': 'OrderedCollection'
|
||||
}
|
||||
boxItems = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'id': boxUrl+pageStr,
|
||||
'id': boxUrl + pageStr,
|
||||
'orderedItems': [
|
||||
],
|
||||
'partOf': boxUrl,
|
||||
|
@ -3266,15 +3266,13 @@ def _createBoxIndexed(recentPostsCache: {},
|
|||
if not isPublicPost(p):
|
||||
continue
|
||||
if p['object'].get('likes'):
|
||||
p['likes'] = {'items': []}
|
||||
if p['object'].get('replies'):
|
||||
p['replies'] = {}
|
||||
if p['object'].get('shares'):
|
||||
p['shares'] = {}
|
||||
if p['object'].get('bookmarks'):
|
||||
p['bookmarks'] = {}
|
||||
if p['object'].get('ignores'):
|
||||
p['ignores'] = {}
|
||||
p['object']['likes'] = {'items': []}
|
||||
removeCollections = {
|
||||
'replies', 'shares', 'bookmarks', 'ignores'
|
||||
}
|
||||
for removeName in removeCollections:
|
||||
if p['object'].get(removeName):
|
||||
p['object'][removeName] = {}
|
||||
|
||||
boxItems['orderedItems'].append(p)
|
||||
|
||||
|
|
Loading…
Reference in New Issue