mirror of https://gitlab.com/bashrc2/epicyon
Alternative field for indicating no replies
parent
d90336239e
commit
6f8060932c
22
inbox.py
22
inbox.py
|
@ -1517,11 +1517,15 @@ def jsonPostAllowsComments(postJsonObject: {}) -> bool:
|
||||||
"""
|
"""
|
||||||
if 'commentsEnabled' in postJsonObject:
|
if 'commentsEnabled' in postJsonObject:
|
||||||
return postJsonObject['commentsEnabled']
|
return postJsonObject['commentsEnabled']
|
||||||
|
if 'rejectReplies' in postJsonObject:
|
||||||
|
return not postJsonObject['rejectReplies']
|
||||||
if postJsonObject.get('object'):
|
if postJsonObject.get('object'):
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
return False
|
return False
|
||||||
elif 'commentsEnabled' in postJsonObject['object']:
|
elif 'commentsEnabled' in postJsonObject['object']:
|
||||||
return postJsonObject['object']['commentsEnabled']
|
return postJsonObject['object']['commentsEnabled']
|
||||||
|
elif 'rejectReplies' in postJsonObject['object']:
|
||||||
|
return not postJsonObject['object']['rejectReplies']
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1576,24 +1580,6 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
||||||
print('DEBUG: post may have expired - ' + replyTo)
|
print('DEBUG: post may have expired - ' + replyTo)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# TODO store replies collection
|
|
||||||
# replyItem = {
|
|
||||||
# "type": "Document",
|
|
||||||
# "url": replyTo
|
|
||||||
# }
|
|
||||||
# if not messageJson['object'].get('replies'):
|
|
||||||
# messageJson['object']['replies'] = {
|
|
||||||
# "items": [replyItem]
|
|
||||||
# }
|
|
||||||
# else:
|
|
||||||
# found = False
|
|
||||||
# for item in messageJson['object']['replies']['items']:
|
|
||||||
# if item['url'] == replyTo:
|
|
||||||
# found = True
|
|
||||||
# break
|
|
||||||
# if not found:
|
|
||||||
# messageJson['object']['replies']['items'].append(replyItem)
|
|
||||||
#
|
|
||||||
if not _postAllowsComments(postFilename):
|
if not _postAllowsComments(postFilename):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post does not allow comments - ' + replyTo)
|
print('DEBUG: post does not allow comments - ' + replyTo)
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -1078,6 +1078,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
'atomUri': newPostId,
|
'atomUri': newPostId,
|
||||||
'inReplyToAtomUri': inReplyToAtomUri,
|
'inReplyToAtomUri': inReplyToAtomUri,
|
||||||
'commentsEnabled': commentsEnabled,
|
'commentsEnabled': commentsEnabled,
|
||||||
|
'rejectReplies': not commentsEnabled,
|
||||||
'mediaType': 'text/html',
|
'mediaType': 'text/html',
|
||||||
'content': content,
|
'content': content,
|
||||||
'contentMap': {
|
'contentMap': {
|
||||||
|
@ -1129,6 +1130,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
'atomUri': newPostId,
|
'atomUri': newPostId,
|
||||||
'inReplyToAtomUri': inReplyToAtomUri,
|
'inReplyToAtomUri': inReplyToAtomUri,
|
||||||
'commentsEnabled': commentsEnabled,
|
'commentsEnabled': commentsEnabled,
|
||||||
|
'rejectReplies': not commentsEnabled,
|
||||||
'mediaType': 'text/html',
|
'mediaType': 'text/html',
|
||||||
'content': content,
|
'content': content,
|
||||||
'contentMap': {
|
'contentMap': {
|
||||||
|
|
10
tests.py
10
tests.py
|
@ -2359,6 +2359,16 @@ def _testJsonPostAllowsComments():
|
||||||
"commentsEnabled": False
|
"commentsEnabled": False
|
||||||
}
|
}
|
||||||
assert not jsonPostAllowsComments(postJsonObject)
|
assert not jsonPostAllowsComments(postJsonObject)
|
||||||
|
postJsonObject = {
|
||||||
|
"id": "123",
|
||||||
|
"rejectReplies": False
|
||||||
|
}
|
||||||
|
assert jsonPostAllowsComments(postJsonObject)
|
||||||
|
postJsonObject = {
|
||||||
|
"id": "123",
|
||||||
|
"rejectReplies": True
|
||||||
|
}
|
||||||
|
assert not jsonPostAllowsComments(postJsonObject)
|
||||||
postJsonObject = {
|
postJsonObject = {
|
||||||
"id": "123",
|
"id": "123",
|
||||||
"commentsEnabled": True
|
"commentsEnabled": True
|
||||||
|
|
38
utils.py
38
utils.py
|
@ -1159,10 +1159,6 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
||||||
return
|
return
|
||||||
if not postJson['attachment'][0].get('url'):
|
if not postJson['attachment'][0].get('url'):
|
||||||
return
|
return
|
||||||
# if port:
|
|
||||||
# if port != 80 and port != 443:
|
|
||||||
# if ':' not in domain:
|
|
||||||
# domain = domain + ':' + str(port)
|
|
||||||
attachmentUrl = postJson['attachment'][0]['url']
|
attachmentUrl = postJson['attachment'][0]['url']
|
||||||
if not attachmentUrl:
|
if not attachmentUrl:
|
||||||
return
|
return
|
||||||
|
@ -1457,18 +1453,21 @@ def noOfActiveAccountsMonthly(baseDir: str, months: int) -> bool:
|
||||||
monthSeconds = int(60*60*24*30*months)
|
monthSeconds = int(60*60*24*30*months)
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for account in dirs:
|
for account in dirs:
|
||||||
if '@' in account:
|
if '@' not in account:
|
||||||
if not account.startswith('inbox@') and \
|
continue
|
||||||
not account.startswith('news@'):
|
if account.startswith('inbox@') or \
|
||||||
lastUsedFilename = \
|
account.startswith('news@'):
|
||||||
baseDir + '/accounts/' + account + '/.lastUsed'
|
continue
|
||||||
if os.path.isfile(lastUsedFilename):
|
lastUsedFilename = \
|
||||||
with open(lastUsedFilename, 'r') as lastUsedFile:
|
baseDir + '/accounts/' + account + '/.lastUsed'
|
||||||
lastUsed = lastUsedFile.read()
|
if not os.path.isfile(lastUsedFilename):
|
||||||
if lastUsed.isdigit():
|
continue
|
||||||
timeDiff = (currTime - int(lastUsed))
|
with open(lastUsedFilename, 'r') as lastUsedFile:
|
||||||
if timeDiff < monthSeconds:
|
lastUsed = lastUsedFile.read()
|
||||||
accountCtr += 1
|
if lastUsed.isdigit():
|
||||||
|
timeDiff = (currTime - int(lastUsed))
|
||||||
|
if timeDiff < monthSeconds:
|
||||||
|
accountCtr += 1
|
||||||
break
|
break
|
||||||
return accountCtr
|
return accountCtr
|
||||||
|
|
||||||
|
@ -1794,13 +1793,6 @@ def getFileCaseInsensitive(path: str) -> str:
|
||||||
if path != path.lower():
|
if path != path.lower():
|
||||||
if os.path.isfile(path.lower()):
|
if os.path.isfile(path.lower()):
|
||||||
return path.lower()
|
return path.lower()
|
||||||
# directory, filename = os.path.split(path)
|
|
||||||
# directory, filename = (directory or '.'), filename.lower()
|
|
||||||
# for f in os.listdir(directory):
|
|
||||||
# if f.lower() == filename:
|
|
||||||
# newpath = os.path.join(directory, f)
|
|
||||||
# if os.path.isfile(newpath):
|
|
||||||
# return newpath
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1401,6 +1401,9 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
if 'commentsEnabled' in postJsonObject['object']:
|
if 'commentsEnabled' in postJsonObject['object']:
|
||||||
if postJsonObject['object']['commentsEnabled'] is False:
|
if postJsonObject['object']['commentsEnabled'] is False:
|
||||||
commentsEnabled = False
|
commentsEnabled = False
|
||||||
|
elif 'rejectReplies' in postJsonObject['object']:
|
||||||
|
if postJsonObject['object']['rejectReplies']:
|
||||||
|
commentsEnabled = False
|
||||||
|
|
||||||
replyStr = _getReplyIconHtml(nickname, isPublicRepeat,
|
replyStr = _getReplyIconHtml(nickname, isPublicRepeat,
|
||||||
showIcons, commentsEnabled,
|
showIcons, commentsEnabled,
|
||||||
|
|
Loading…
Reference in New Issue