Load all lists and then enable them selectively

merge-requests/30/head
Bob Mottram 2021-10-21 20:00:25 +01:00
parent 7d2b5aa1b3
commit 9ecb745d3d
13 changed files with 176 additions and 121 deletions

View File

@ -876,11 +876,9 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
return False
def loadCWLists(baseDir: str, verbose: bool, listsEnabled: str) -> {}:
def loadCWLists(baseDir: str, verbose: bool) -> {}:
"""Load lists used for content warnings
"""
if not listsEnabled:
return {}
if not os.path.isdir(baseDir + '/cwlists'):
return {}
result = {}
@ -895,8 +893,6 @@ def loadCWLists(baseDir: str, verbose: bool, listsEnabled: str) -> {}:
continue
if not listJson.get('name'):
continue
if listJson['name'] not in listsEnabled:
continue
if not listJson.get('words') and not listJson.get('domains'):
continue
name = listJson['name']
@ -906,10 +902,13 @@ def loadCWLists(baseDir: str, verbose: bool, listsEnabled: str) -> {}:
return result
def addCWfromLists(postJsonObject: {}, CWlists: {}, translate: {}) -> None:
def addCWfromLists(postJsonObject: {}, CWlists: {}, translate: {},
listsEnabled: str) -> None:
"""Adds content warnings by matching the post content
against domains or keywords
"""
if not listsEnabled:
return
if not postJsonObject['object'].get('content'):
return
cw = ''
@ -918,6 +917,8 @@ def addCWfromLists(postJsonObject: {}, CWlists: {}, translate: {}) -> None:
content = postJsonObject['object']['content']
for name, item in CWlists.items():
if name not in listsEnabled:
continue
if not item.get('warning'):
continue
warning = item['warning']

108
daemon.py
View File

@ -1231,7 +1231,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.themeName,
self.server.maxLikeCount,
self.server.maxRecentPosts,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
def _postToOutboxThread(self, messageJson: {}) -> bool:
"""Creates a thread to send a post
@ -3010,7 +3011,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if hashtagStr:
msg = hashtagStr.encode('utf-8')
msglen = len(msg)
@ -3069,7 +3071,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if historyStr:
msg = historyStr.encode('utf-8')
msglen = len(msg)
@ -3108,7 +3111,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if bookmarksStr:
msg = bookmarksStr.encode('utf-8')
msglen = len(msg)
@ -3213,7 +3217,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if profileStr:
msg = profileStr.encode('utf-8')
msglen = len(msg)
@ -6734,7 +6739,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if hashtagStr:
msg = hashtagStr.encode('utf-8')
msglen = len(msg)
@ -6957,7 +6963,8 @@ class PubServer(BaseHTTPRequestHandler):
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
self.server.GETbusy = False
actorAbsolute = self._getInstanceUrl(callingDomain) + actor
@ -7439,7 +7446,8 @@ class PubServer(BaseHTTPRequestHandler):
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Liked post not found: ' + likedPostFilename)
# clear the icon from the cache so that it gets updated
@ -7600,7 +7608,8 @@ class PubServer(BaseHTTPRequestHandler):
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Unliked post not found: ' + likedPostFilename)
# clear the icon from the cache so that it gets updated
@ -7736,7 +7745,8 @@ class PubServer(BaseHTTPRequestHandler):
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Bookmarked post not found: ' + bookmarkFilename)
# self._postToOutbox(bookmarkJson, self.server.projectVersion, None)
@ -7871,7 +7881,8 @@ class PubServer(BaseHTTPRequestHandler):
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Unbookmarked post not found: ' + bookmarkFilename)
self.server.GETbusy = False
@ -7974,7 +7985,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if deleteStr:
deleteStrLen = len(deleteStr)
self._set_headers('text/html', deleteStrLen,
@ -8083,7 +8095,8 @@ class PubServer(BaseHTTPRequestHandler):
manuallyApproveFollowers,
showPublicOnly, storeToCache,
useCacheOnly,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Muted post not found: ' + muteFilename)
@ -8193,7 +8206,8 @@ class PubServer(BaseHTTPRequestHandler):
manuallyApproveFollowers,
showPublicOnly, storeToCache,
useCacheOnly,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
else:
print('WARN: Unmuted post not found: ' + muteFilename)
self.server.GETbusy = False
@ -8317,7 +8331,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -8417,7 +8432,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -8526,7 +8542,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
rolesList,
None, None, self.server.CWlists)
None, None, self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -8640,7 +8657,8 @@ class PubServer(BaseHTTPRequestHandler):
sharedItemsFederatedDomains,
skills,
None, None,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -8790,7 +8808,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.systemLanguage,
self.server.maxLikeCount,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9037,7 +9056,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
if GETstartTime:
fitnessPerformance(GETstartTime,
self.server.fitness,
@ -9186,7 +9206,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9328,7 +9349,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9469,7 +9491,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9610,7 +9633,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9760,7 +9784,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -9908,7 +9933,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10015,7 +10041,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10100,7 +10127,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10222,7 +10250,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10361,7 +10390,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10491,7 +10521,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
sharedItemsFederatedDomains,
self.server.signingPrivateKeyPem,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10619,7 +10650,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.sharedItemsFederatedDomains,
shares,
pageNumber, sharesPerPage,
self.server.CWlists)
self.server.CWlists,
self.server.listsEnabled)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -10744,7 +10776,8 @@ class PubServer(BaseHTTPRequestHandler):
following,
pageNumber,
followsPerPage,
self.server.CWlists).encode('utf-8')
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html',
msglen, cookie, callingDomain, False)
@ -10868,7 +10901,8 @@ class PubServer(BaseHTTPRequestHandler):
followers,
pageNumber,
followsPerPage,
self.server.CWlists).encode('utf-8')
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain, False)
@ -11008,7 +11042,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.maxLikeCount,
self.server.sharedItemsFederatedDomains,
None, None, None,
self.server.CWlists).encode('utf-8')
self.server.CWlists,
self.server.listsEnabled).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain, False)
@ -17226,8 +17261,7 @@ def runDaemon(listsEnabled: str,
httpd.listsEnabled = listsEnabled
else:
httpd.listsEnabled = getConfigParam(baseDir, "listsEnabled")
httpd.CWlists = loadCWLists(baseDir, True, httpd.listsEnabled)
print('CWlistsStr httpd.CWlists: ' + str(httpd.CWlists))
httpd.CWlists = loadCWLists(baseDir, True)
# set the avatar for the news account
httpd.themeName = getConfigParam(baseDir, 'theme')

View File

@ -275,7 +275,8 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, maxRecentPosts: int,
themeName: str, systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str,
CWlists: {}) -> None:
CWlists: {},
listsEnabled: str) -> None:
"""Converts the json post into html and stores it in a cache
This enables the post to be quickly displayed later
"""
@ -300,7 +301,7 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, maxRecentPosts: int,
peertubeInstances, allowLocalNetworkAccess,
themeName, systemLanguage, maxLikeCount,
notDM, True, True, False, True, False,
CWlists)
CWlists, listsEnabled)
def validInbox(baseDir: str, nickname: str, domain: str) -> bool:
@ -982,7 +983,8 @@ def _receiveLike(recentPostsCache: {},
peertubeInstances: [],
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, CWlists: {}) -> bool:
maxLikeCount: int, CWlists: {},
listsEnabled: str) -> bool:
"""Receives a Like activity within the POST section of HTTPServer
"""
if messageJson['type'] != 'Like':
@ -1084,7 +1086,8 @@ def _receiveLike(recentPostsCache: {},
maxLikeCount, notDM,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False, CWlists)
False, True, False, CWlists,
listsEnabled)
return True
@ -1102,7 +1105,8 @@ def _receiveUndoLike(recentPostsCache: {},
peertubeInstances: [],
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, CWlists: {}) -> bool:
maxLikeCount: int, CWlists: {},
listsEnabled: str) -> bool:
"""Receives an undo like activity within the POST section of HTTPServer
"""
if messageJson['type'] != 'Undo':
@ -1193,7 +1197,8 @@ def _receiveUndoLike(recentPostsCache: {},
maxLikeCount, notDM,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False, CWlists)
False, True, False, CWlists,
listsEnabled)
return True
@ -1210,7 +1215,8 @@ def _receiveBookmark(recentPostsCache: {},
peertubeInstances: [],
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, CWlists: {}) -> bool:
maxLikeCount: int, CWlists: {},
listsEnabled: {}) -> bool:
"""Receives a bookmark activity within the POST section of HTTPServer
"""
if not messageJson.get('type'):
@ -1301,7 +1307,8 @@ def _receiveBookmark(recentPostsCache: {},
maxLikeCount, notDM,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False, CWlists)
False, True, False, CWlists,
listsEnabled)
return True
@ -1318,7 +1325,8 @@ def _receiveUndoBookmark(recentPostsCache: {},
peertubeInstances: [],
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, CWlists: {}) -> bool:
maxLikeCount: int, CWlists: {},
listsEnabled: str) -> bool:
"""Receives an undo bookmark activity within the POST section of HTTPServer
"""
if not messageJson.get('type'):
@ -1410,7 +1418,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
maxLikeCount, notDM,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False, CWlists)
False, True, False, CWlists, listsEnabled)
return True
@ -1504,7 +1512,8 @@ def _receiveAnnounce(recentPostsCache: {},
maxRecentPosts: int,
allowDeletion: bool,
peertubeInstances: [],
maxLikeCount: int, CWlists: {}) -> bool:
maxLikeCount: int, CWlists: {},
listsEnabled: str) -> bool:
"""Receives an announce activity within the POST section of HTTPServer
"""
if messageJson['type'] != 'Announce':
@ -1616,7 +1625,8 @@ def _receiveAnnounce(recentPostsCache: {},
maxLikeCount, notDM,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False, CWlists)
False, True, False, CWlists,
listsEnabled)
if not announceHtml:
print('WARN: Unable to generate html for announce ' +
str(messageJson))
@ -2554,7 +2564,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
maxLikeCount: int,
signingPrivateKeyPem: str,
defaultReplyIntervalHours: int,
CWlists: {}) -> bool:
CWlists: {}, listsEnabled: str) -> bool:
""" Anything which needs to be done after initial checks have passed
"""
actor = keyId
@ -2584,7 +2594,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
peertubeInstances,
allowLocalNetworkAccess,
themeName, systemLanguage,
maxLikeCount, CWlists):
maxLikeCount, CWlists, listsEnabled):
if debug:
print('DEBUG: Like accepted from ' + actor)
return False
@ -2606,7 +2616,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
peertubeInstances,
allowLocalNetworkAccess,
themeName, systemLanguage,
maxLikeCount, CWlists):
maxLikeCount, CWlists, listsEnabled):
if debug:
print('DEBUG: Undo like accepted from ' + actor)
return False
@ -2628,7 +2638,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
peertubeInstances,
allowLocalNetworkAccess,
themeName, systemLanguage,
maxLikeCount, CWlists):
maxLikeCount, CWlists, listsEnabled):
if debug:
print('DEBUG: Bookmark accepted from ' + actor)
return False
@ -2650,7 +2660,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
peertubeInstances,
allowLocalNetworkAccess,
themeName, systemLanguage,
maxLikeCount, CWlists):
maxLikeCount, CWlists, listsEnabled):
if debug:
print('DEBUG: Undo bookmark accepted from ' + actor)
return False
@ -2676,7 +2686,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
maxRecentPosts,
allowDeletion,
peertubeInstances,
maxLikeCount, CWlists):
maxLikeCount, CWlists, listsEnabled):
if debug:
print('DEBUG: Announce accepted from ' + actor)
@ -2958,7 +2968,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
themeName, systemLanguage,
maxLikeCount,
signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
if debug:
timeDiff = \
str(int((time.time() - htmlCacheStartTime) *
@ -3631,6 +3641,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
if not os.path.isfile(sharedInboxPostFilename):
saveJson(queueJson['post'], sharedInboxPostFilename)
listsEnabled = getConfigParam(baseDir, "listsEnabled")
# for posts addressed to specific accounts
for handle, capsId in recipientsDict.items():
destination = \
@ -3662,7 +3674,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
maxLikeCount,
signingPrivateKeyPem,
defaultReplyIntervalHours,
CWlists)
CWlists, listsEnabled)
if debug:
pprint(queueJson['post'])
print('Queue: Queue post accepted')

View File

@ -196,7 +196,8 @@ def postMessageToOutbox(session, translate: {},
signingPrivateKeyPem: str,
peertubeInstances: str, theme: str,
maxLikeCount: int,
maxRecentPosts: int, CWlists: {}) -> bool:
maxRecentPosts: int, CWlists: {},
listsEnabled: str) -> bool:
"""post is received by the outbox
Client to server message post
https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery
@ -468,7 +469,7 @@ def postMessageToOutbox(session, translate: {},
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, useCacheOnly,
CWlists)
CWlists, listsEnabled)
if outboxAnnounce(recentPostsCache,
baseDir, messageJson, debug):

View File

@ -125,7 +125,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
httpd.themeName,
httpd.maxLikeCount,
httpd.maxRecentPosts,
httpd.CWlists):
httpd.CWlists,
httpd.listsEnabled):
indexLines.remove(line)
try:
os.remove(postFilename)

View File

@ -5773,7 +5773,7 @@ def _testWordsSimilarity() -> None:
def _testAddCWfromLists(baseDir: str) -> None:
print('testAddCWfromLists')
translate = {}
CWlists = loadCWLists(baseDir, True, "Murdoch press")
CWlists = loadCWLists(baseDir, True)
assert CWlists
postJsonObject = {
@ -5783,7 +5783,7 @@ def _testAddCWfromLists(baseDir: str) -> None:
"content": ""
}
}
addCWfromLists(postJsonObject, CWlists, translate)
addCWfromLists(postJsonObject, CWlists, translate, 'Murdoch press')
assert postJsonObject['object']['sensitive'] is False
assert postJsonObject['object']['summary'] is None
@ -5794,7 +5794,7 @@ def _testAddCWfromLists(baseDir: str) -> None:
"content": "Blah blah news.co.uk blah blah"
}
}
addCWfromLists(postJsonObject, CWlists, translate)
addCWfromLists(postJsonObject, CWlists, translate, 'Murdoch press')
assert postJsonObject['object']['sensitive'] is True
assert postJsonObject['object']['summary'] == "Murdoch Press"
@ -5805,7 +5805,7 @@ def _testAddCWfromLists(baseDir: str) -> None:
"content": "Blah blah news.co.uk blah blah"
}
}
addCWfromLists(postJsonObject, CWlists, translate)
addCWfromLists(postJsonObject, CWlists, translate, 'Murdoch press')
assert postJsonObject['object']['sensitive'] is True
assert postJsonObject['object']['summary'] == "Murdoch Press / Existing CW"

View File

@ -36,7 +36,7 @@ def htmlConfirmDelete(cssCache: {},
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Shows a screen asking to confirm the deletion of a post
"""
if '/statuses/' not in messageId:
@ -81,7 +81,7 @@ def htmlConfirmDelete(cssCache: {},
peertubeInstances, allowLocalNetworkAccess,
themeName, systemLanguage, maxLikeCount,
False, False, False, False, False, False,
CWlists)
CWlists, listsEnabled)
deletePostStr += '<center>'
deletePostStr += \
' <p class="followText">' + \

View File

@ -35,7 +35,8 @@ def _htmlFrontScreenPosts(recentPostsCache: {}, maxRecentPosts: int,
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str, CWlists: {}) -> str:
signingPrivateKeyPem: str, CWlists: {},
listsEnabled: str) -> str:
"""Shows posts on the front screen of a news instance
These should only be public blog posts from the features timeline
which is the blog timeline of the news actor
@ -82,7 +83,7 @@ def _htmlFrontScreenPosts(recentPostsCache: {}, maxRecentPosts: int,
maxLikeCount,
False, False, False,
True, False, False,
CWlists)
CWlists, listsEnabled)
if postStr:
profileStr += postStr + separatorStr
ctr += 1
@ -113,7 +114,7 @@ def htmlFrontScreen(signingPrivateKeyPem: str,
extraJson: {},
pageNumber: int,
maxItemsPerPage: int,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the news instance front screen
"""
nickname = profileJson['preferredUsername']
@ -185,7 +186,7 @@ def htmlFrontScreen(signingPrivateKeyPem: str,
theme, systemLanguage,
maxLikeCount,
signingPrivateKeyPem,
CWlists) + licenseStr
CWlists, listsEnabled) + licenseStr
# Footer which is only used for system accounts
profileFooterStr = ' </td>\n'

View File

@ -53,7 +53,7 @@ def htmlModeration(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the moderation feed as html
This is what you see when selecting the "mod" timeline
"""
@ -73,7 +73,7 @@ def htmlModeration(cssCache: {}, defaultTimeline: str,
peertubeInstances, allowLocalNetworkAccess,
textModeBanner, accessKeys, systemLanguage,
maxLikeCount, sharedItemsFederatedDomains,
signingPrivateKeyPem, CWlists)
signingPrivateKeyPem, CWlists, listsEnabled)
def htmlAccountInfo(cssCache: {}, translate: {},

View File

@ -1207,7 +1207,8 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
showPublicOnly: bool,
storeToCache: bool,
useCacheOnly: bool,
CWlists: {}) -> str:
CWlists: {},
listsEnabled: str) -> str:
""" Shows a single post as html
"""
if not postJsonObject:
@ -1654,7 +1655,7 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
footerStr = newFooterStr
# add any content warning from the cwlists directory
addCWfromLists(postJsonObject, CWlists, translate)
addCWfromLists(postJsonObject, CWlists, translate, listsEnabled)
postIsSensitive = False
if postJsonObject['object'].get('sensitive'):
@ -1831,7 +1832,7 @@ def htmlIndividualPost(cssCache: {},
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int, signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show an individual post as html
"""
postStr = ''
@ -1885,7 +1886,7 @@ def htmlIndividualPost(cssCache: {},
allowLocalNetworkAccess, themeName,
systemLanguage, maxLikeCount,
False, authorized, False, False, False, False,
CWlists)
CWlists, listsEnabled)
messageId = removeIdEnding(postJsonObject['id'])
# show the previous posts
@ -1918,7 +1919,7 @@ def htmlIndividualPost(cssCache: {},
maxLikeCount,
False, authorized,
False, False, False, False,
CWlists) + postStr
CWlists, listsEnabled) + postStr
# show the following posts
postFilename = locatePost(baseDir, nickname, domain, messageId)
@ -1953,7 +1954,7 @@ def htmlIndividualPost(cssCache: {},
maxLikeCount,
False, authorized,
False, False, False, False,
CWlists)
CWlists, listsEnabled)
cssFilename = baseDir + '/epicyon-profile.css'
if os.path.isfile(baseDir + '/epicyon.css'):
cssFilename = baseDir + '/epicyon.css'
@ -1977,7 +1978,8 @@ def htmlPostReplies(cssCache: {},
allowLocalNetworkAccess: bool,
themeName: str, systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str, CWlists: {}) -> str:
signingPrivateKeyPem: str, CWlists: {},
listsEnabled: str) -> str:
"""Show the replies to an individual post as html
"""
repliesStr = ''
@ -2001,7 +2003,7 @@ def htmlPostReplies(cssCache: {},
themeName, systemLanguage,
maxLikeCount,
False, False, False, False, False, False,
CWlists)
CWlists, listsEnabled)
cssFilename = baseDir + '/epicyon-profile.css'
if os.path.isfile(baseDir + '/epicyon.css'):

View File

@ -90,7 +90,7 @@ def htmlProfileAfterSearch(cssCache: {},
systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show a profile page after a search for a fediverse address
"""
http = False
@ -308,7 +308,7 @@ def htmlProfileAfterSearch(cssCache: {},
allowLocalNetworkAccess,
themeName, systemLanguage, maxLikeCount,
False, False, False, False, False, False,
CWlists)
CWlists, listsEnabled)
i += 1
if i >= 8:
break
@ -520,7 +520,7 @@ def htmlProfile(signingPrivateKeyPem: str,
sharedItemsFederatedDomains: [],
extraJson: {}, pageNumber: int,
maxItemsPerPage: int,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the profile page as html
"""
nickname = profileJson['preferredUsername']
@ -543,7 +543,8 @@ def htmlProfile(signingPrivateKeyPem: str,
allowLocalNetworkAccess, accessKeys,
systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, None,
pageNumber, maxItemsPerPage, CWlists)
pageNumber, maxItemsPerPage, CWlists,
listsEnabled)
domain, port = getDomainFromActor(profileJson['id'])
if not domain:
@ -901,7 +902,7 @@ def htmlProfile(signingPrivateKeyPem: str,
theme, systemLanguage,
maxLikeCount,
signingPrivateKeyPem,
CWlists) + licenseStr
CWlists, listsEnabled) + licenseStr
if not isGroup:
if selected == 'following':
profileStr += \
@ -968,7 +969,7 @@ def _htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
themeName: str, systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Shows posts on the profile screen
These should only be public posts
"""
@ -1014,7 +1015,7 @@ def _htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
maxLikeCount,
False, False, False,
True, False, False,
CWlists)
CWlists, listsEnabled)
if postStr:
profileStr += postStr + separatorStr
ctr += 1

View File

@ -599,7 +599,8 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {},
listsEnabled: str) -> str:
"""Show a page containing search results for your post history
"""
if historysearch.startswith("'"):
@ -685,7 +686,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
showIndividualPostIcons,
showIndividualPostIcons,
False, False, False, False,
CWlists)
CWlists, listsEnabled)
if postStr:
historySearchForm += separatorStr + postStr
index += 1
@ -710,7 +711,7 @@ def htmlHashtagSearch(cssCache: {},
themeName: str, systemLanguage: str,
maxLikeCount: int,
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show a page containing search results for a hashtag
or after selecting a hashtag from the swarm
"""
@ -868,7 +869,8 @@ def htmlHashtagSearch(cssCache: {},
showRepeats, showIcons,
manuallyApprovesFollowers,
showPublicOnly,
storeToCache, False, CWlists)
storeToCache, False, CWlists,
listsEnabled)
if postStr:
hashtagSearchForm += separatorStr + postStr
index += 1

View File

@ -447,7 +447,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the timeline as html
"""
enableTimingLog = False
@ -915,7 +915,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, useCacheOnly,
CWlists)
CWlists, listsEnabled)
_logTimelineTiming(enableTimingLog,
timelineStartTime, boxName, '12')
@ -1140,7 +1140,7 @@ def htmlShares(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the shares timeline as html
"""
manuallyApproveFollowers = \
@ -1166,7 +1166,7 @@ def htmlShares(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlWanted(cssCache: {}, defaultTimeline: str,
@ -1194,7 +1194,7 @@ def htmlWanted(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the wanted timeline as html
"""
manuallyApproveFollowers = \
@ -1220,7 +1220,7 @@ def htmlWanted(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInbox(cssCache: {}, defaultTimeline: str,
@ -1249,7 +1249,7 @@ def htmlInbox(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the inbox as html
"""
manuallyApproveFollowers = \
@ -1275,7 +1275,7 @@ def htmlInbox(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlBookmarks(cssCache: {}, defaultTimeline: str,
@ -1304,7 +1304,7 @@ def htmlBookmarks(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the bookmarks as html
"""
manuallyApproveFollowers = \
@ -1330,7 +1330,7 @@ def htmlBookmarks(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxDMs(cssCache: {}, defaultTimeline: str,
@ -1359,7 +1359,7 @@ def htmlInboxDMs(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the DM timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1380,7 +1380,7 @@ def htmlInboxDMs(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxReplies(cssCache: {}, defaultTimeline: str,
@ -1409,7 +1409,7 @@ def htmlInboxReplies(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the replies timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1431,7 +1431,7 @@ def htmlInboxReplies(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxMedia(cssCache: {}, defaultTimeline: str,
@ -1460,7 +1460,7 @@ def htmlInboxMedia(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the media timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1482,7 +1482,7 @@ def htmlInboxMedia(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxBlogs(cssCache: {}, defaultTimeline: str,
@ -1511,7 +1511,7 @@ def htmlInboxBlogs(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the blogs timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1533,7 +1533,7 @@ def htmlInboxBlogs(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxFeatures(cssCache: {}, defaultTimeline: str,
@ -1563,7 +1563,7 @@ def htmlInboxFeatures(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the features timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1585,7 +1585,7 @@ def htmlInboxFeatures(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlInboxNews(cssCache: {}, defaultTimeline: str,
@ -1614,7 +1614,7 @@ def htmlInboxNews(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the news timeline as html
"""
return htmlTimeline(cssCache, defaultTimeline,
@ -1636,7 +1636,7 @@ def htmlInboxNews(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)
def htmlOutbox(cssCache: {}, defaultTimeline: str,
@ -1665,7 +1665,7 @@ def htmlOutbox(cssCache: {}, defaultTimeline: str,
maxLikeCount: int,
sharedItemsFederatedDomains: [],
signingPrivateKeyPem: str,
CWlists: {}) -> str:
CWlists: {}, listsEnabled: str) -> str:
"""Show the Outbox as html
"""
manuallyApproveFollowers = \
@ -1688,4 +1688,4 @@ def htmlOutbox(cssCache: {}, defaultTimeline: str,
allowLocalNetworkAccess, textModeBanner,
accessKeys, systemLanguage, maxLikeCount,
sharedItemsFederatedDomains, signingPrivateKeyPem,
CWlists)
CWlists, listsEnabled)