mirror of https://gitlab.com/bashrc2/epicyon
Remove debug
parent
d3fc9ee45e
commit
df03b54f43
|
@ -525,23 +525,18 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
lowBandwidth: bool) -> None:
|
lowBandwidth: bool) -> None:
|
||||||
"""Converts rss items in a newswire into posts
|
"""Converts rss items in a newswire into posts
|
||||||
"""
|
"""
|
||||||
print('newswire convertRSStoActivityPub 1')
|
|
||||||
if not newswire:
|
if not newswire:
|
||||||
print('No newswire to convert')
|
print('No newswire to convert')
|
||||||
return
|
return
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 2')
|
|
||||||
basePath = baseDir + '/accounts/news@' + domain + '/outbox'
|
basePath = baseDir + '/accounts/news@' + domain + '/outbox'
|
||||||
if not os.path.isdir(basePath):
|
if not os.path.isdir(basePath):
|
||||||
os.mkdir(basePath)
|
os.mkdir(basePath)
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 3')
|
|
||||||
# oldest items first
|
# oldest items first
|
||||||
newswireReverse = OrderedDict(sorted(newswire.items(), reverse=False))
|
newswireReverse = OrderedDict(sorted(newswire.items(), reverse=False))
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 4')
|
|
||||||
for dateStr, item in newswireReverse.items():
|
for dateStr, item in newswireReverse.items():
|
||||||
print('newswire convertRSStoActivityPub 5')
|
|
||||||
originalDateStr = dateStr
|
originalDateStr = dateStr
|
||||||
# convert the date to the format used by ActivityPub
|
# convert the date to the format used by ActivityPub
|
||||||
if '+00:00' in dateStr:
|
if '+00:00' in dateStr:
|
||||||
|
@ -561,13 +556,11 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
str(dateStrWithOffset))
|
str(dateStrWithOffset))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 6')
|
|
||||||
statusNumber, published = getStatusNumber(dateStr)
|
statusNumber, published = getStatusNumber(dateStr)
|
||||||
newPostId = \
|
newPostId = \
|
||||||
localActorUrl(httpPrefix, 'news', domain) + \
|
localActorUrl(httpPrefix, 'news', domain) + \
|
||||||
'/statuses/' + statusNumber
|
'/statuses/' + statusNumber
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 7')
|
|
||||||
# file where the post is stored
|
# file where the post is stored
|
||||||
filename = basePath + '/' + newPostId.replace('/', '#') + '.json'
|
filename = basePath + '/' + newPostId.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
@ -579,7 +572,6 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
newswire[originalDateStr][3] = filename
|
newswire[originalDateStr][3] = filename
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 8')
|
|
||||||
rssTitle = _removeControlCharacters(item[0])
|
rssTitle = _removeControlCharacters(item[0])
|
||||||
url = item[1]
|
url = item[1]
|
||||||
if dangerousMarkup(url, allowLocalNetworkAccess) or \
|
if dangerousMarkup(url, allowLocalNetworkAccess) or \
|
||||||
|
@ -587,7 +579,6 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
continue
|
continue
|
||||||
rssDescription = ''
|
rssDescription = ''
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 9')
|
|
||||||
# get the rss description if it exists
|
# get the rss description if it exists
|
||||||
rssDescription = '<p>' + removeHtml(item[4]) + '<p>'
|
rssDescription = '<p>' + removeHtml(item[4]) + '<p>'
|
||||||
|
|
||||||
|
@ -606,7 +597,6 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
'<br><a href="' + postUrl + '">' + \
|
'<br><a href="' + postUrl + '">' + \
|
||||||
translate['Read more...'] + '</a>'
|
translate['Read more...'] + '</a>'
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 10')
|
|
||||||
followersOnly = False
|
followersOnly = False
|
||||||
# NOTE: the id when the post is created will not be
|
# NOTE: the id when the post is created will not be
|
||||||
# consistent (it's based on the current time, not the
|
# consistent (it's based on the current time, not the
|
||||||
|
@ -627,14 +617,12 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
conversationId, lowBandwidth)
|
conversationId, lowBandwidth)
|
||||||
if not blog:
|
if not blog:
|
||||||
continue
|
continue
|
||||||
print('newswire convertRSStoActivityPub 11')
|
|
||||||
|
|
||||||
if mirrored:
|
if mirrored:
|
||||||
if not _createNewsMirror(baseDir, domain, statusNumber,
|
if not _createNewsMirror(baseDir, domain, statusNumber,
|
||||||
url, maxMirroredArticles):
|
url, maxMirroredArticles):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 12')
|
|
||||||
idStr = \
|
idStr = \
|
||||||
localActorUrl(httpPrefix, 'news', domain) + \
|
localActorUrl(httpPrefix, 'news', domain) + \
|
||||||
'/statuses/' + statusNumber + '/replies'
|
'/statuses/' + statusNumber + '/replies'
|
||||||
|
@ -658,7 +646,6 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
blog['object']['content'] = rssDescription
|
blog['object']['content'] = rssDescription
|
||||||
blog['object']['contentMap'][systemLanguage] = rssDescription
|
blog['object']['contentMap'][systemLanguage] = rssDescription
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 13')
|
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
|
||||||
hashtags = item[6]
|
hashtags = item[6]
|
||||||
|
@ -667,14 +654,12 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
moderated = item[5]
|
moderated = item[5]
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 14')
|
|
||||||
savePost = _newswireHashtagProcessing(session, baseDir, blog, hashtags,
|
savePost = _newswireHashtagProcessing(session, baseDir, blog, hashtags,
|
||||||
httpPrefix, domain, port,
|
httpPrefix, domain, port,
|
||||||
personCache, cachedWebfingers,
|
personCache, cachedWebfingers,
|
||||||
federationList,
|
federationList,
|
||||||
sendThreads, postLog,
|
sendThreads, postLog,
|
||||||
moderated, url, systemLanguage)
|
moderated, url, systemLanguage)
|
||||||
print('newswire convertRSStoActivityPub 15')
|
|
||||||
|
|
||||||
# save the post and update the index
|
# save the post and update the index
|
||||||
if savePost:
|
if savePost:
|
||||||
|
@ -713,10 +698,8 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
if tag not in newswire[originalDateStr][6]:
|
if tag not in newswire[originalDateStr][6]:
|
||||||
newswire[originalDateStr][6].append(tag)
|
newswire[originalDateStr][6].append(tag)
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 16')
|
|
||||||
storeHashTags(baseDir, 'news', blog)
|
storeHashTags(baseDir, 'news', blog)
|
||||||
|
|
||||||
print('newswire convertRSStoActivityPub 17')
|
|
||||||
clearFromPostCaches(baseDir, recentPostsCache, postId)
|
clearFromPostCaches(baseDir, recentPostsCache, postId)
|
||||||
if saveJson(blog, filename):
|
if saveJson(blog, filename):
|
||||||
_updateFeedsOutboxIndex(baseDir, domain, postId + '.json')
|
_updateFeedsOutboxIndex(baseDir, domain, postId + '.json')
|
||||||
|
@ -741,7 +724,6 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
# set the filename
|
# set the filename
|
||||||
newswire[originalDateStr][3] = filename
|
newswire[originalDateStr][3] = filename
|
||||||
print('newswire convertRSStoActivityPub 18')
|
|
||||||
|
|
||||||
|
|
||||||
def _mergeWithPreviousNewswire(oldNewswire: {}, newNewswire: {}) -> None:
|
def _mergeWithPreviousNewswire(oldNewswire: {}, newNewswire: {}) -> None:
|
||||||
|
|
Loading…
Reference in New Issue