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:
|
||||
return postJsonObject['commentsEnabled']
|
||||
if 'rejectReplies' in postJsonObject:
|
||||
return not postJsonObject['rejectReplies']
|
||||
if postJsonObject.get('object'):
|
||||
if not hasObjectDict(postJsonObject):
|
||||
return False
|
||||
elif 'commentsEnabled' in postJsonObject['object']:
|
||||
return postJsonObject['object']['commentsEnabled']
|
||||
elif 'rejectReplies' in postJsonObject['object']:
|
||||
return not postJsonObject['object']['rejectReplies']
|
||||
return True
|
||||
|
||||
|
||||
|
@ -1576,24 +1580,6 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
|||
print('DEBUG: post may have expired - ' + replyTo)
|
||||
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 debug:
|
||||
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,
|
||||
'inReplyToAtomUri': inReplyToAtomUri,
|
||||
'commentsEnabled': commentsEnabled,
|
||||
'rejectReplies': not commentsEnabled,
|
||||
'mediaType': 'text/html',
|
||||
'content': content,
|
||||
'contentMap': {
|
||||
|
@ -1129,6 +1130,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
|||
'atomUri': newPostId,
|
||||
'inReplyToAtomUri': inReplyToAtomUri,
|
||||
'commentsEnabled': commentsEnabled,
|
||||
'rejectReplies': not commentsEnabled,
|
||||
'mediaType': 'text/html',
|
||||
'content': content,
|
||||
'contentMap': {
|
||||
|
|
10
tests.py
10
tests.py
|
@ -2359,6 +2359,16 @@ def _testJsonPostAllowsComments():
|
|||
"commentsEnabled": False
|
||||
}
|
||||
assert not jsonPostAllowsComments(postJsonObject)
|
||||
postJsonObject = {
|
||||
"id": "123",
|
||||
"rejectReplies": False
|
||||
}
|
||||
assert jsonPostAllowsComments(postJsonObject)
|
||||
postJsonObject = {
|
||||
"id": "123",
|
||||
"rejectReplies": True
|
||||
}
|
||||
assert not jsonPostAllowsComments(postJsonObject)
|
||||
postJsonObject = {
|
||||
"id": "123",
|
||||
"commentsEnabled": True
|
||||
|
|
38
utils.py
38
utils.py
|
@ -1159,10 +1159,6 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
|||
return
|
||||
if not postJson['attachment'][0].get('url'):
|
||||
return
|
||||
# if port:
|
||||
# if port != 80 and port != 443:
|
||||
# if ':' not in domain:
|
||||
# domain = domain + ':' + str(port)
|
||||
attachmentUrl = postJson['attachment'][0]['url']
|
||||
if not attachmentUrl:
|
||||
return
|
||||
|
@ -1457,18 +1453,21 @@ def noOfActiveAccountsMonthly(baseDir: str, months: int) -> bool:
|
|||
monthSeconds = int(60*60*24*30*months)
|
||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||
for account in dirs:
|
||||
if '@' in account:
|
||||
if not account.startswith('inbox@') and \
|
||||
not account.startswith('news@'):
|
||||
lastUsedFilename = \
|
||||
baseDir + '/accounts/' + account + '/.lastUsed'
|
||||
if os.path.isfile(lastUsedFilename):
|
||||
with open(lastUsedFilename, 'r') as lastUsedFile:
|
||||
lastUsed = lastUsedFile.read()
|
||||
if lastUsed.isdigit():
|
||||
timeDiff = (currTime - int(lastUsed))
|
||||
if timeDiff < monthSeconds:
|
||||
accountCtr += 1
|
||||
if '@' not in account:
|
||||
continue
|
||||
if account.startswith('inbox@') or \
|
||||
account.startswith('news@'):
|
||||
continue
|
||||
lastUsedFilename = \
|
||||
baseDir + '/accounts/' + account + '/.lastUsed'
|
||||
if not os.path.isfile(lastUsedFilename):
|
||||
continue
|
||||
with open(lastUsedFilename, 'r') as lastUsedFile:
|
||||
lastUsed = lastUsedFile.read()
|
||||
if lastUsed.isdigit():
|
||||
timeDiff = (currTime - int(lastUsed))
|
||||
if timeDiff < monthSeconds:
|
||||
accountCtr += 1
|
||||
break
|
||||
return accountCtr
|
||||
|
||||
|
@ -1794,13 +1793,6 @@ def getFileCaseInsensitive(path: str) -> str:
|
|||
if path != path.lower():
|
||||
if os.path.isfile(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
|
||||
|
||||
|
||||
|
|
|
@ -1401,6 +1401,9 @@ def individualPostAsHtml(allowDownloads: bool,
|
|||
if 'commentsEnabled' in postJsonObject['object']:
|
||||
if postJsonObject['object']['commentsEnabled'] is False:
|
||||
commentsEnabled = False
|
||||
elif 'rejectReplies' in postJsonObject['object']:
|
||||
if postJsonObject['object']['rejectReplies']:
|
||||
commentsEnabled = False
|
||||
|
||||
replyStr = _getReplyIconHtml(nickname, isPublicRepeat,
|
||||
showIcons, commentsEnabled,
|
||||
|
|
Loading…
Reference in New Issue