mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon
commit
784a31466e
|
|
@ -38,7 +38,7 @@ def _createAcceptReject(baseDir: str, federationList: [],
|
||||||
newAccept = {
|
newAccept = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': acceptType,
|
'type': acceptType,
|
||||||
'actor': httpPrefix+'://' + domain + '/users/' + nickname,
|
'actor': httpPrefix + '://' + domain + '/users/' + nickname,
|
||||||
'to': [toUrl],
|
'to': [toUrl],
|
||||||
'cc': [],
|
'cc': [],
|
||||||
'object': objectJson
|
'object': objectJson
|
||||||
|
|
@ -120,9 +120,9 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
print('DEBUG: unrecognized actor ' + thisActor)
|
print('DEBUG: unrecognized actor ' + thisActor)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if not '/' + acceptedDomain+'/users/' + nickname in thisActor:
|
if not '/' + acceptedDomain + '/users/' + nickname in thisActor:
|
||||||
if debug:
|
if debug:
|
||||||
print('Expected: /' + acceptedDomain+'/users/' + nickname)
|
print('Expected: /' + acceptedDomain + '/users/' + nickname)
|
||||||
print('Actual: ' + thisActor)
|
print('Actual: ' + thisActor)
|
||||||
print('DEBUG: unrecognized actor ' + thisActor)
|
print('DEBUG: unrecognized actor ' + thisActor)
|
||||||
return
|
return
|
||||||
|
|
@ -134,7 +134,7 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
return
|
return
|
||||||
followedDomainFull = followedDomain
|
followedDomainFull = followedDomain
|
||||||
if port:
|
if port:
|
||||||
followedDomainFull = followedDomain+':' + str(port)
|
followedDomainFull = followedDomain + ':' + str(port)
|
||||||
followedNickname = getNicknameFromActor(followedActor)
|
followedNickname = getNicknameFromActor(followedActor)
|
||||||
if not followedNickname:
|
if not followedNickname:
|
||||||
print('DEBUG: no nickname found within Follow activity object ' +
|
print('DEBUG: no nickname found within Follow activity object ' +
|
||||||
|
|
@ -168,7 +168,7 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Unable to create follow - ' +
|
print('DEBUG: Unable to create follow - ' +
|
||||||
nickname + '@' + acceptedDomain+' -> ' +
|
nickname + '@' + acceptedDomain + ' -> ' +
|
||||||
followedNickname + '@' + followedDomain)
|
followedNickname + '@' + followedDomain)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,9 +198,10 @@ def sendAnnounceViaServer(baseDir: str, session,
|
||||||
statusNumber, published = getStatusNumber()
|
statusNumber, published = getStatusNumber()
|
||||||
newAnnounceId = httpPrefix + '://' + fromDomainFull + '/users/' + \
|
newAnnounceId = httpPrefix + '://' + fromDomainFull + '/users/' + \
|
||||||
fromNickname + '/statuses/' + statusNumber
|
fromNickname + '/statuses/' + statusNumber
|
||||||
|
actorStr = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname
|
||||||
newAnnounceJson = {
|
newAnnounceJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
|
'actor': actorStr,
|
||||||
'atomUri': newAnnounceId,
|
'atomUri': newAnnounceId,
|
||||||
'cc': [ccUrl],
|
'cc': [ccUrl],
|
||||||
'id': newAnnounceId + '/activity',
|
'id': newAnnounceId + '/activity',
|
||||||
|
|
|
||||||
4
auth.py
4
auth.py
|
|
@ -126,7 +126,7 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
||||||
') does not match the one in the Authorization header (' +
|
') does not match the one in the Authorization header (' +
|
||||||
nickname + ')')
|
nickname + ')')
|
||||||
return False
|
return False
|
||||||
passwordFile = baseDir+'/accounts/passwords'
|
passwordFile = baseDir + '/accounts/passwords'
|
||||||
if not os.path.isfile(passwordFile):
|
if not os.path.isfile(passwordFile):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: passwords file missing')
|
print('DEBUG: passwords file missing')
|
||||||
|
|
@ -134,7 +134,7 @@ def authorizeBasic(baseDir: str, path: str, authHeader: str,
|
||||||
providedPassword = plain.split(':')[1]
|
providedPassword = plain.split(':')[1]
|
||||||
passfile = open(passwordFile, "r")
|
passfile = open(passwordFile, "r")
|
||||||
for line in passfile:
|
for line in passfile:
|
||||||
if line.startswith(nickname+':'):
|
if line.startswith(nickname + ':'):
|
||||||
storedPassword = \
|
storedPassword = \
|
||||||
line.split(':')[1].replace('\n', '').replace('\r', '')
|
line.split(':')[1].replace('\n', '').replace('\r', '')
|
||||||
success = _verifyPassword(storedPassword, providedPassword)
|
success = _verifyPassword(storedPassword, providedPassword)
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,8 @@ def sendAvailabilityViaServer(baseDir: str, session,
|
||||||
|
|
||||||
newAvailabilityJson = {
|
newAvailabilityJson = {
|
||||||
'type': 'Availability',
|
'type': 'Availability',
|
||||||
'actor': httpPrefix+'://'+domainFull+'/users/'+nickname,
|
'actor': httpPrefix + '://' + domainFull + '/users/' + nickname,
|
||||||
'object': '"'+status+'"',
|
'object': '"' + status + '"',
|
||||||
'to': [toUrl],
|
'to': [toUrl],
|
||||||
'cc': [ccUrl]
|
'cc': [ccUrl]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
blocking.py
19
blocking.py
|
|
@ -39,10 +39,8 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block an account handle or domain
|
# block an account handle or domain
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
if blockFile:
|
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
blockFile.close()
|
|
||||||
else:
|
else:
|
||||||
blockHashtag = blockNickname
|
blockHashtag = blockNickname
|
||||||
# is the hashtag already blocked?
|
# is the hashtag already blocked?
|
||||||
|
|
@ -50,10 +48,8 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHashtag + '\n' in open(blockingFilename).read():
|
if blockHashtag + '\n' in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block a hashtag
|
# block a hashtag
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
if blockFile:
|
|
||||||
blockFile.write(blockHashtag + '\n')
|
blockFile.write(blockHashtag + '\n')
|
||||||
blockFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -69,9 +65,8 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(blockingFilename):
|
if os.path.isfile(blockingFilename):
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
blockFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -493,10 +488,8 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
|
||||||
muteFile = open(postFilename + '.muted', 'w+')
|
with open(postFilename + '.muted', 'w+') as muteFile:
|
||||||
if muteFile:
|
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
|
||||||
print('MUTE: ' + postFilename + '.muted file added')
|
print('MUTE: ' + postFilename + '.muted file added')
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as muted
|
# if the post is in the recent posts cache then mark it as muted
|
||||||
|
|
@ -751,12 +744,10 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
# write the allow file
|
# write the allow file
|
||||||
allowFile = open(allowFilename, "w+")
|
with open(allowFilename, 'w+') as allowFile:
|
||||||
if allowFile:
|
|
||||||
allowFile.write(domainFull + '\n')
|
allowFile.write(domainFull + '\n')
|
||||||
for d in allowedDomains:
|
for d in allowedDomains:
|
||||||
allowFile.write(d + '\n')
|
allowFile.write(d + '\n')
|
||||||
allowFile.close()
|
|
||||||
print('Broch mode enabled')
|
print('Broch mode enabled')
|
||||||
|
|
||||||
setConfigParam(baseDir, "brochMode", enabled)
|
setConfigParam(baseDir, "brochMode", enabled)
|
||||||
|
|
|
||||||
14
bookmarks.py
14
bookmarks.py
|
|
@ -61,10 +61,8 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
indexStr = ''
|
indexStr = ''
|
||||||
with open(bookmarksIndexFilename, 'r') as indexFile:
|
with open(bookmarksIndexFilename, 'r') as indexFile:
|
||||||
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w+')
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
if bookmarksIndexFile:
|
|
||||||
bookmarksIndexFile.write(indexStr)
|
bookmarksIndexFile.write(indexStr)
|
||||||
bookmarksIndexFile.close()
|
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
|
|
@ -219,10 +217,8 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
print('WARN: Failed to write entry to bookmarks index ' +
|
print('WARN: Failed to write entry to bookmarks index ' +
|
||||||
bookmarksIndexFilename + ' ' + str(e))
|
bookmarksIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w+')
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
if bookmarksIndexFile:
|
|
||||||
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
||||||
bookmarksIndexFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def bookmark(recentPostsCache: {},
|
def bookmark(recentPostsCache: {},
|
||||||
|
|
@ -247,7 +243,7 @@ def bookmark(recentPostsCache: {},
|
||||||
newBookmarkJson = {
|
newBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Bookmark',
|
'type': 'Bookmark',
|
||||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
'actor': httpPrefix + '://' + fullDomain + '/users/' + nickname,
|
||||||
'object': objectUrl
|
'object': objectUrl
|
||||||
}
|
}
|
||||||
if ccList:
|
if ccList:
|
||||||
|
|
@ -306,10 +302,10 @@ def undoBookmark(recentPostsCache: {},
|
||||||
newUndoBookmarkJson = {
|
newUndoBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Undo',
|
'type': 'Undo',
|
||||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
'actor': httpPrefix + '://' + fullDomain + '/users/' + nickname,
|
||||||
'object': {
|
'object': {
|
||||||
'type': 'Bookmark',
|
'type': 'Bookmark',
|
||||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
'actor': httpPrefix + '://' + fullDomain + '/users/' + nickname,
|
||||||
'object': objectUrl
|
'object': objectUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
cache.py
11
cache.py
|
|
@ -20,7 +20,7 @@ def _removePersonFromCache(baseDir: str, personUrl: str,
|
||||||
"""Removes an actor from the cache
|
"""Removes an actor from the cache
|
||||||
"""
|
"""
|
||||||
cacheFilename = baseDir + '/cache/actors/' + \
|
cacheFilename = baseDir + '/cache/actors/' + \
|
||||||
personUrl.replace('/', '#')+'.json'
|
personUrl.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(cacheFilename):
|
if os.path.isfile(cacheFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cacheFilename)
|
os.remove(cacheFilename)
|
||||||
|
|
@ -66,10 +66,11 @@ def storePersonInCache(baseDir: str, personUrl: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
# store to file
|
# store to file
|
||||||
if allowWriteToFile:
|
if not allowWriteToFile:
|
||||||
if os.path.isdir(baseDir+'/cache/actors'):
|
return
|
||||||
|
if os.path.isdir(baseDir + '/cache/actors'):
|
||||||
cacheFilename = baseDir + '/cache/actors/' + \
|
cacheFilename = baseDir + '/cache/actors/' + \
|
||||||
personUrl.replace('/', '#')+'.json'
|
personUrl.replace('/', '#') + '.json'
|
||||||
if not os.path.isfile(cacheFilename):
|
if not os.path.isfile(cacheFilename):
|
||||||
saveJson(personJson, cacheFilename)
|
saveJson(personJson, cacheFilename)
|
||||||
|
|
||||||
|
|
@ -83,7 +84,7 @@ def getPersonFromCache(baseDir: str, personUrl: str, personCache: {},
|
||||||
if not personCache.get(personUrl):
|
if not personCache.get(personUrl):
|
||||||
# does the person exist as a cached file?
|
# does the person exist as a cached file?
|
||||||
cacheFilename = baseDir + '/cache/actors/' + \
|
cacheFilename = baseDir + '/cache/actors/' + \
|
||||||
personUrl.replace('/', '#')+'.json'
|
personUrl.replace('/', '#') + '.json'
|
||||||
actorFilename = getFileCaseInsensitive(cacheFilename)
|
actorFilename = getFileCaseInsensitive(cacheFilename)
|
||||||
if actorFilename:
|
if actorFilename:
|
||||||
personJson = loadJson(actorFilename)
|
personJson = loadJson(actorFilename)
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ def _addMusicTag(content: str, tag: str) -> str:
|
||||||
musicSites = ('soundcloud.com', 'bandcamp.com')
|
musicSites = ('soundcloud.com', 'bandcamp.com')
|
||||||
musicSiteFound = False
|
musicSiteFound = False
|
||||||
for site in musicSites:
|
for site in musicSites:
|
||||||
if site+'/' in content:
|
if site + '/' in content:
|
||||||
musicSiteFound = True
|
musicSiteFound = True
|
||||||
break
|
break
|
||||||
if not musicSiteFound:
|
if not musicSiteFound:
|
||||||
|
|
@ -458,7 +458,7 @@ def _addEmoji(baseDir: str, wordStr: str,
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': emojiUrl
|
'url': emojiUrl
|
||||||
},
|
},
|
||||||
'name': ':'+emoji+':',
|
'name': ':' + emoji + ':',
|
||||||
"updated": fileLastModified(emojiFilename),
|
"updated": fileLastModified(emojiFilename),
|
||||||
"id": emojiUrl.replace('.png', ''),
|
"id": emojiUrl.replace('.png', ''),
|
||||||
'type': 'Emoji'
|
'type': 'Emoji'
|
||||||
|
|
@ -820,7 +820,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
||||||
continue
|
continue
|
||||||
elif ':' in wordStr:
|
elif ':' in wordStr:
|
||||||
wordStr2 = wordStr.split(':')[1]
|
wordStr2 = wordStr.split(':')[1]
|
||||||
# print('TAG: emoji located - '+wordStr)
|
# print('TAG: emoji located - ' + wordStr)
|
||||||
if not emojiDict:
|
if not emojiDict:
|
||||||
# emoji.json is generated so that it can be customized and
|
# emoji.json is generated so that it can be customized and
|
||||||
# the changes will be retained even if default_emoji.json
|
# the changes will be retained even if default_emoji.json
|
||||||
|
|
@ -830,7 +830,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
||||||
baseDir + '/emoji/emoji.json')
|
baseDir + '/emoji/emoji.json')
|
||||||
emojiDict = loadJson(baseDir + '/emoji/emoji.json')
|
emojiDict = loadJson(baseDir + '/emoji/emoji.json')
|
||||||
|
|
||||||
# print('TAG: looking up emoji for :'+wordStr2+':')
|
# print('TAG: looking up emoji for :' + wordStr2 + ':')
|
||||||
_addEmoji(baseDir, ':' + wordStr2 + ':', httpPrefix,
|
_addEmoji(baseDir, ':' + wordStr2 + ':', httpPrefix,
|
||||||
originalDomain, replaceEmoji, hashtags,
|
originalDomain, replaceEmoji, hashtags,
|
||||||
emojiDict)
|
emojiDict)
|
||||||
|
|
|
||||||
91
daemon.py
91
daemon.py
|
|
@ -431,10 +431,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.maxReplies,
|
self.server.maxReplies,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
# record the vote
|
# record the vote
|
||||||
votesFile = open(votesFilename, 'a+')
|
with open(votesFilename, 'a+') as votesFile:
|
||||||
if votesFile:
|
|
||||||
votesFile.write(messageId + '\n')
|
votesFile.write(messageId + '\n')
|
||||||
votesFile.close()
|
|
||||||
|
|
||||||
# ensure that the cached post is removed if it exists,
|
# ensure that the cached post is removed if it exists,
|
||||||
# so that it then will be recreated
|
# so that it then will be recreated
|
||||||
|
|
@ -1534,7 +1532,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# This produces a deterministic token based
|
# This produces a deterministic token based
|
||||||
# on nick+password+salt
|
# on nick+password+salt
|
||||||
saltFilename = \
|
saltFilename = \
|
||||||
baseDir+'/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
loginNickname + '@' + domain + '/.salt'
|
loginNickname + '@' + domain + '/.salt'
|
||||||
salt = createPassword(32)
|
salt = createPassword(32)
|
||||||
if os.path.isfile(saltFilename):
|
if os.path.isfile(saltFilename):
|
||||||
|
|
@ -1557,7 +1555,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.tokens[loginNickname] = token
|
self.server.tokens[loginNickname] = token
|
||||||
loginHandle = loginNickname + '@' + domain
|
loginHandle = loginNickname + '@' + domain
|
||||||
tokenFilename = \
|
tokenFilename = \
|
||||||
baseDir+'/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
loginHandle + '/.token'
|
loginHandle + '/.token'
|
||||||
try:
|
try:
|
||||||
with open(tokenFilename, 'w+') as fp:
|
with open(tokenFilename, 'w+') as fp:
|
||||||
|
|
@ -2104,10 +2102,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
noNewswireFile = open(newswireBlockedFilename, "w+")
|
nwFilename = newswireBlockedFilename
|
||||||
if noNewswireFile:
|
with open(nwFilename, 'w+') as noNewswireFile:
|
||||||
noNewswireFile.write('\n')
|
noNewswireFile.write('\n')
|
||||||
noNewswireFile.close()
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
|
@ -2140,10 +2137,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
noFeaturesFile = open(featuresBlockedFilename, "w+")
|
featFilename = featuresBlockedFilename
|
||||||
if noFeaturesFile:
|
with open(featFilename, 'w+') as noFeaturesFile:
|
||||||
noFeaturesFile.write('\n')
|
noFeaturesFile.write('\n')
|
||||||
noFeaturesFile.close()
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
|
@ -2175,10 +2171,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(newswireModFilename)
|
os.remove(newswireModFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
modNewswireFile = open(newswireModFilename, "w+")
|
nwFilename = newswireModFilename
|
||||||
if modNewswireFile:
|
with open(nwFilename, 'w+') as modNewswireFile:
|
||||||
modNewswireFile.write('\n')
|
modNewswireFile.write('\n')
|
||||||
modNewswireFile.close()
|
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
|
@ -3459,10 +3454,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if fields.get('editedLinks'):
|
if fields.get('editedLinks'):
|
||||||
linksStr = fields['editedLinks']
|
linksStr = fields['editedLinks']
|
||||||
linksFile = open(linksFilename, "w+")
|
with open(linksFilename, 'w+') as linksFile:
|
||||||
if linksFile:
|
|
||||||
linksFile.write(linksStr)
|
linksFile.write(linksStr)
|
||||||
linksFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(linksFilename):
|
if os.path.isfile(linksFilename):
|
||||||
os.remove(linksFilename)
|
os.remove(linksFilename)
|
||||||
|
|
@ -3474,10 +3467,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aboutStr = fields['editedAbout']
|
aboutStr = fields['editedAbout']
|
||||||
if not dangerousMarkup(aboutStr,
|
if not dangerousMarkup(aboutStr,
|
||||||
allowLocalNetworkAccess):
|
allowLocalNetworkAccess):
|
||||||
aboutFile = open(aboutFilename, "w+")
|
with open(aboutFilename, 'w+') as aboutFile:
|
||||||
if aboutFile:
|
|
||||||
aboutFile.write(aboutStr)
|
aboutFile.write(aboutStr)
|
||||||
aboutFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(aboutFilename):
|
if os.path.isfile(aboutFilename):
|
||||||
os.remove(aboutFilename)
|
os.remove(aboutFilename)
|
||||||
|
|
@ -3486,10 +3477,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
TOSStr = fields['editedTOS']
|
TOSStr = fields['editedTOS']
|
||||||
if not dangerousMarkup(TOSStr,
|
if not dangerousMarkup(TOSStr,
|
||||||
allowLocalNetworkAccess):
|
allowLocalNetworkAccess):
|
||||||
TOSFile = open(TOSFilename, "w+")
|
with open(TOSFilename, 'w+') as TOSFile:
|
||||||
if TOSFile:
|
|
||||||
TOSFile.write(TOSStr)
|
TOSFile.write(TOSStr)
|
||||||
TOSFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(TOSFilename):
|
if os.path.isfile(TOSFilename):
|
||||||
os.remove(TOSFilename)
|
os.remove(TOSFilename)
|
||||||
|
|
@ -3664,10 +3653,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
extractTextFieldsInPOST(postBytes, boundary, debug)
|
extractTextFieldsInPOST(postBytes, boundary, debug)
|
||||||
if fields.get('editedNewswire'):
|
if fields.get('editedNewswire'):
|
||||||
newswireStr = fields['editedNewswire']
|
newswireStr = fields['editedNewswire']
|
||||||
newswireFile = open(newswireFilename, "w+")
|
with open(newswireFilename, 'w+') as newswireFile:
|
||||||
if newswireFile:
|
|
||||||
newswireFile.write(newswireStr)
|
newswireFile.write(newswireStr)
|
||||||
newswireFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswireFilename):
|
||||||
os.remove(newswireFilename)
|
os.remove(newswireFilename)
|
||||||
|
|
@ -3698,10 +3685,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newswireTrusted = fields['trustedNewswire']
|
newswireTrusted = fields['trustedNewswire']
|
||||||
if not newswireTrusted.endswith('\n'):
|
if not newswireTrusted.endswith('\n'):
|
||||||
newswireTrusted += '\n'
|
newswireTrusted += '\n'
|
||||||
trustFile = open(newswireTrustedFilename, "w+")
|
with open(newswireTrustedFilename, 'w+') as trustFile:
|
||||||
if trustFile:
|
|
||||||
trustFile.write(newswireTrusted)
|
trustFile.write(newswireTrusted)
|
||||||
trustFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireTrustedFilename):
|
if os.path.isfile(newswireTrustedFilename):
|
||||||
os.remove(newswireTrustedFilename)
|
os.remove(newswireTrustedFilename)
|
||||||
|
|
@ -3787,10 +3772,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
citationsStr += citationDate + '\n'
|
citationsStr += citationDate + '\n'
|
||||||
# save citations dates, so that they can be added when
|
# save citations dates, so that they can be added when
|
||||||
# reloading the newblog screen
|
# reloading the newblog screen
|
||||||
citationsFile = open(citationsFilename, "w+")
|
with open(citationsFilename, 'w+') as citationsFile:
|
||||||
if citationsFile:
|
|
||||||
citationsFile.write(citationsStr)
|
citationsFile.write(citationsStr)
|
||||||
citationsFile.close()
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/newblog',
|
self._redirect_headers(actorStr + '/newblog',
|
||||||
|
|
@ -4710,8 +4693,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearModeratorStatus(baseDir)
|
clearModeratorStatus(baseDir)
|
||||||
if ',' in fields['moderators']:
|
if ',' in fields['moderators']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
modFile = open(moderatorsFile, "w+")
|
|
||||||
mods = fields['moderators'].split(',')
|
mods = fields['moderators'].split(',')
|
||||||
|
with open(moderatorsFile, 'w+') as modFile:
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = baseDir + \
|
modDir = baseDir + \
|
||||||
|
|
@ -4719,8 +4702,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(modDir):
|
if os.path.isdir(modDir):
|
||||||
modFile.write(modNick + '\n')
|
modFile.write(modNick + '\n')
|
||||||
modFile.close()
|
|
||||||
mods = fields['moderators'].split(',')
|
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = baseDir + \
|
modDir = baseDir + \
|
||||||
|
|
@ -4732,8 +4714,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'moderator')
|
'moderator')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
modFile = open(moderatorsFile, "w+")
|
|
||||||
mods = fields['moderators'].split('\n')
|
mods = fields['moderators'].split('\n')
|
||||||
|
with open(moderatorsFile, 'w+') as modFile:
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = \
|
modDir = \
|
||||||
|
|
@ -4742,8 +4724,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(modDir):
|
if os.path.isdir(modDir):
|
||||||
modFile.write(modNick + '\n')
|
modFile.write(modNick + '\n')
|
||||||
modFile.close()
|
|
||||||
mods = fields['moderators'].split('\n')
|
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = \
|
modDir = \
|
||||||
|
|
@ -4766,8 +4747,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearEditorStatus(baseDir)
|
clearEditorStatus(baseDir)
|
||||||
if ',' in fields['editors']:
|
if ',' in fields['editors']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(editorsFile, "w+")
|
|
||||||
eds = fields['editors'].split(',')
|
eds = fields['editors'].split(',')
|
||||||
|
with open(editorsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4775,8 +4756,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['editors'].split(',')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4788,8 +4768,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'editor')
|
'editor')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(editorsFile, "w+")
|
|
||||||
eds = fields['editors'].split('\n')
|
eds = fields['editors'].split('\n')
|
||||||
|
with open(editorsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -4798,8 +4778,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['editors'].split('\n')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -4822,8 +4801,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearCounselorStatus(baseDir)
|
clearCounselorStatus(baseDir)
|
||||||
if ',' in fields['counselors']:
|
if ',' in fields['counselors']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(counselorsFile, "w+")
|
|
||||||
eds = fields['counselors'].split(',')
|
eds = fields['counselors'].split(',')
|
||||||
|
with open(counselorsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4831,8 +4810,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['counselors'].split(',')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4844,8 +4822,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'counselor')
|
'counselor')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(counselorsFile, "w+")
|
|
||||||
eds = fields['counselors'].split('\n')
|
eds = fields['counselors'].split('\n')
|
||||||
|
with open(counselorsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -4854,8 +4832,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['counselors'].split('\n')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -4878,8 +4855,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearArtistStatus(baseDir)
|
clearArtistStatus(baseDir)
|
||||||
if ',' in fields['artists']:
|
if ',' in fields['artists']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(artistsFile, "w+")
|
|
||||||
eds = fields['artists'].split(',')
|
eds = fields['artists'].split(',')
|
||||||
|
with open(artistsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4887,8 +4864,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['artists'].split(',')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
|
@ -4900,8 +4876,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'artist')
|
'artist')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(artistsFile, "w+")
|
|
||||||
eds = fields['artists'].split('\n')
|
eds = fields['artists'].split('\n')
|
||||||
|
with open(artistsFile, 'w+') as edFile:
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -4910,8 +4886,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'@' + domain
|
'@' + domain
|
||||||
if os.path.isdir(edDir):
|
if os.path.isdir(edDir):
|
||||||
edFile.write(edNick + '\n')
|
edFile.write(edNick + '\n')
|
||||||
edFile.close()
|
|
||||||
eds = fields['artists'].split('\n')
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
|
@ -13327,10 +13302,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.baseDir + '/accounts/' + \
|
self.server.baseDir + '/accounts/' + \
|
||||||
nickname + '@' + self.server.domain + '/.lastUsed'
|
nickname + '@' + self.server.domain + '/.lastUsed'
|
||||||
try:
|
try:
|
||||||
lastUsedFile = open(lastUsedFilename, 'w+')
|
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
||||||
if lastUsedFile:
|
|
||||||
lastUsedFile.write(str(int(time.time())))
|
lastUsedFile.write(str(int(time.time())))
|
||||||
lastUsedFile.close()
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,10 +175,8 @@ def _markPostAsRead(actor: str, postId: str, postCategory: str) -> None:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Failed to mark post as read' + str(e))
|
print('WARN: Failed to mark post as read' + str(e))
|
||||||
else:
|
else:
|
||||||
readFile = open(readPostsFilename, 'w+')
|
with open(readPostsFilename, 'w+') as readFile:
|
||||||
if readFile:
|
|
||||||
readFile.write(postId + '\n')
|
readFile.write(postId + '\n')
|
||||||
readFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _hasReadPost(actor: str, postId: str, postCategory: str) -> bool:
|
def _hasReadPost(actor: str, postId: str, postCategory: str) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -1092,7 +1092,7 @@ if args.message:
|
||||||
toDomain = 'public'
|
toDomain = 'public'
|
||||||
toPort = port
|
toPort = port
|
||||||
|
|
||||||
# ccUrl=httpPrefix+'://'+domain+'/users/'+nickname+'/followers'
|
# ccUrl = httpPrefix + '://' + domain + '/users/' + nickname + '/followers'
|
||||||
ccUrl = None
|
ccUrl = None
|
||||||
sendMessage = args.message
|
sendMessage = args.message
|
||||||
followersOnly = args.followersonly
|
followersOnly = args.followersonly
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@ def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
filtersFile = open(filtersFilename, "a+")
|
with open(filtersFilename, 'a+') as filtersFile:
|
||||||
filtersFile.write(words + '\n')
|
filtersFile.write(words + '\n')
|
||||||
filtersFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,9 +34,8 @@ def addGlobalFilter(baseDir: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
filtersFile = open(filtersFilename, "a+")
|
with open(filtersFilename, 'a+') as filtersFile:
|
||||||
filtersFile.write(words + '\n')
|
filtersFile.write(words + '\n')
|
||||||
filtersFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ def _removeFromFollowBase(baseDir: str,
|
||||||
break
|
break
|
||||||
if not actorFound:
|
if not actorFound:
|
||||||
return
|
return
|
||||||
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
with open(approveFollowsFilename + '.new', 'w+') as approvefilenew:
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
if not acceptDenyActor:
|
if not acceptDenyActor:
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
|
|
@ -125,7 +125,7 @@ def _removeFromFollowBase(baseDir: str,
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
if acceptDenyActor not in approveHandle:
|
if acceptDenyActor not in approveHandle:
|
||||||
approvefilenew.write(approveHandle)
|
approvefilenew.write(approveHandle)
|
||||||
approvefilenew.close()
|
|
||||||
os.rename(approveFollowsFilename + '.new', approveFollowsFilename)
|
os.rename(approveFollowsFilename + '.new', approveFollowsFilename)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -765,9 +765,8 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
'Failed to write entry to followers file ' +
|
'Failed to write entry to followers file ' +
|
||||||
str(e))
|
str(e))
|
||||||
else:
|
else:
|
||||||
followersFile = open(followersFilename, "w+")
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandle + '\n')
|
followersFile.write(approveHandle + '\n')
|
||||||
followersFile.close()
|
|
||||||
|
|
||||||
print('Beginning follow accept')
|
print('Beginning follow accept')
|
||||||
return followedAccountAccepts(session, baseDir, httpPrefix,
|
return followedAccountAccepts(session, baseDir, httpPrefix,
|
||||||
|
|
|
||||||
23
happening.py
23
happening.py
|
|
@ -105,9 +105,8 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
tlEventsFilename + ' ' + str(e))
|
tlEventsFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
tlEventsFile = open(tlEventsFilename, 'w+')
|
with open(tlEventsFilename, 'w+') as tlEventsFile:
|
||||||
tlEventsFile.write(eventId + '\n')
|
tlEventsFile.write(eventId + '\n')
|
||||||
tlEventsFile.close()
|
|
||||||
|
|
||||||
# create a directory for the calendar year
|
# create a directory for the calendar year
|
||||||
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
||||||
|
|
@ -124,27 +123,20 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# append the post Id to the file for the calendar month
|
# append the post Id to the file for the calendar month
|
||||||
calendarFile = open(calendarFilename, 'a+')
|
with open(calendarFilename, 'a+') as calendarFile:
|
||||||
if not calendarFile:
|
|
||||||
return False
|
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
# create a file which will trigger a notification that
|
# create a file which will trigger a notification that
|
||||||
# a new event has been added
|
# a new event has been added
|
||||||
calendarNotificationFilename = \
|
calendarNotificationFilename = \
|
||||||
baseDir + '/accounts/' + handle + '/.newCalendar'
|
baseDir + '/accounts/' + handle + '/.newCalendar'
|
||||||
calendarNotificationFile = \
|
with open(calendarNotificationFilename, 'w+') as calendarNotificationFile:
|
||||||
open(calendarNotificationFilename, 'w+')
|
|
||||||
if not calendarNotificationFile:
|
|
||||||
return False
|
|
||||||
calendarNotificationFile.write('/calendar?year=' +
|
calendarNotificationFile.write('/calendar?year=' +
|
||||||
str(eventYear) +
|
str(eventYear) +
|
||||||
'?month=' +
|
'?month=' +
|
||||||
str(eventMonthNumber) +
|
str(eventMonthNumber) +
|
||||||
'?day=' +
|
'?day=' +
|
||||||
str(eventDayOfMonth))
|
str(eventDayOfMonth))
|
||||||
calendarNotificationFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -251,10 +243,9 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
@ -368,10 +359,9 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
@ -433,10 +423,9 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
|
||||||
36
inbox.py
36
inbox.py
|
|
@ -127,10 +127,8 @@ def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||||
daysSinceEpoch = daysDiff.days
|
daysSinceEpoch = daysDiff.days
|
||||||
tagline = str(daysSinceEpoch) + ' ' + nickname + ' ' + postUrl + '\n'
|
tagline = str(daysSinceEpoch) + ' ' + nickname + ' ' + postUrl + '\n'
|
||||||
if not os.path.isfile(tagsFilename):
|
if not os.path.isfile(tagsFilename):
|
||||||
tagsFile = open(tagsFilename, "w+")
|
with open(tagsFilename, 'w+') as tagsFile:
|
||||||
if tagsFile:
|
|
||||||
tagsFile.write(tagline)
|
tagsFile.write(tagline)
|
||||||
tagsFile.close()
|
|
||||||
else:
|
else:
|
||||||
if postUrl not in open(tagsFilename).read():
|
if postUrl not in open(tagsFilename).read():
|
||||||
try:
|
try:
|
||||||
|
|
@ -191,7 +189,7 @@ def validInbox(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""
|
"""
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
domain = domain.split(':')[0]
|
domain = domain.split(':')[0]
|
||||||
inboxDir = baseDir+'/accounts/' + nickname + '@' + domain + '/inbox'
|
inboxDir = baseDir + '/accounts/' + nickname + '@' + domain + '/inbox'
|
||||||
if not os.path.isdir(inboxDir):
|
if not os.path.isdir(inboxDir):
|
||||||
return True
|
return True
|
||||||
for subdir, dirs, files in os.walk(inboxDir):
|
for subdir, dirs, files in os.walk(inboxDir):
|
||||||
|
|
@ -508,7 +506,7 @@ def _inboxPostRecipientsAdd(baseDir: str, httpPrefix: str, toList: [],
|
||||||
if domainMatch in recipient:
|
if domainMatch in recipient:
|
||||||
# get the handle for the local account
|
# get the handle for the local account
|
||||||
nickname = recipient.split(domainMatch)[1]
|
nickname = recipient.split(domainMatch)[1]
|
||||||
handle = nickname+'@'+domain
|
handle = nickname + '@' + domain
|
||||||
if os.path.isdir(baseDir + '/accounts/' + handle):
|
if os.path.isdir(baseDir + '/accounts/' + handle):
|
||||||
recipientsDict[handle] = None
|
recipientsDict[handle] = None
|
||||||
else:
|
else:
|
||||||
|
|
@ -1460,10 +1458,8 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, lookupActor,
|
translate, lookupActor,
|
||||||
themeName)
|
themeName)
|
||||||
ttsFile = open(postFilename + '.tts', "w+")
|
with open(postFilename + '.tts', 'w+') as ttsFile:
|
||||||
if ttsFile:
|
|
||||||
ttsFile.write('\n')
|
ttsFile.write('\n')
|
||||||
ttsFile.close()
|
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Obtaining actor for announce post ' +
|
print('DEBUG: Obtaining actor for announce post ' +
|
||||||
|
|
@ -1642,15 +1638,11 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
||||||
if numLines > maxReplies:
|
if numLines > maxReplies:
|
||||||
return False
|
return False
|
||||||
if messageId not in open(postRepliesFilename).read():
|
if messageId not in open(postRepliesFilename).read():
|
||||||
repliesFile = open(postRepliesFilename, 'a+')
|
with open(postRepliesFilename, 'a+') as repliesFile:
|
||||||
if repliesFile:
|
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
|
||||||
else:
|
else:
|
||||||
repliesFile = open(postRepliesFilename, 'w+')
|
with open(postRepliesFilename, 'w+') as repliesFile:
|
||||||
if repliesFile:
|
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2107,10 +2099,8 @@ def inboxUpdateIndex(boxname: str, baseDir: str, handle: str,
|
||||||
print('WARN: Failed to write entry to index ' + str(e))
|
print('WARN: Failed to write entry to index ' + str(e))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
indexFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(destinationFilename + '\n')
|
indexFile.write(destinationFilename + '\n')
|
||||||
indexFile.close()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Failed to write initial entry to index ' + str(e))
|
print('WARN: Failed to write initial entry to index ' + str(e))
|
||||||
|
|
||||||
|
|
@ -2590,10 +2580,8 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
# This enables you to ignore a threat that's getting boring
|
# This enables you to ignore a threat that's getting boring
|
||||||
if isReplyToMutedPost:
|
if isReplyToMutedPost:
|
||||||
print('MUTE REPLY: ' + destinationFilename)
|
print('MUTE REPLY: ' + destinationFilename)
|
||||||
muteFile = open(destinationFilename + '.muted', 'w+')
|
with open(destinationFilename + '.muted', 'w+') as muteFile:
|
||||||
if muteFile:
|
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
|
||||||
|
|
||||||
# update the indexes for different timelines
|
# update the indexes for different timelines
|
||||||
for boxname in updateIndexList:
|
for boxname in updateIndexList:
|
||||||
|
|
@ -2851,10 +2839,8 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
unknownFile = open(unknownContextsFile, "a+")
|
with open(unknownContextsFile, 'a+') as unknownFile:
|
||||||
if unknownFile:
|
|
||||||
unknownFile.write(unknownContext + '\n')
|
unknownFile.write(unknownContext + '\n')
|
||||||
unknownFile.close()
|
|
||||||
else:
|
else:
|
||||||
print('Unrecognized jsonld signature type: ' +
|
print('Unrecognized jsonld signature type: ' +
|
||||||
jwebsigType)
|
jwebsigType)
|
||||||
|
|
@ -2869,10 +2855,8 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
unknownFile = open(unknownSignaturesFile, "a+")
|
with open(unknownSignaturesFile, 'a+') as unknownFile:
|
||||||
if unknownFile:
|
|
||||||
unknownFile.write(jwebsigType + '\n')
|
unknownFile.write(jwebsigType + '\n')
|
||||||
unknownFile.close()
|
|
||||||
return hasJsonSignature, jwebsigType
|
return hasJsonSignature, jwebsigType
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,8 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
||||||
|
|
||||||
# Store rejected follows
|
# Store rejected follows
|
||||||
rejectsFile = open(rejectedFollowsFilename, "a+")
|
with open(rejectedFollowsFilename, 'a+') as rejectsFile:
|
||||||
rejectsFile.write(denyHandle + '\n')
|
rejectsFile.write(denyHandle + '\n')
|
||||||
rejectsFile.close()
|
|
||||||
|
|
||||||
denyNickname = denyHandle.split('@')[0]
|
denyNickname = denyHandle.split('@')[0]
|
||||||
denyDomain = \
|
denyDomain = \
|
||||||
|
|
@ -70,13 +69,11 @@ def _approveFollowerHandle(accountDir: str, approveHandle: str) -> None:
|
||||||
approvedFilename = accountDir + '/approved.txt'
|
approvedFilename = accountDir + '/approved.txt'
|
||||||
if os.path.isfile(approvedFilename):
|
if os.path.isfile(approvedFilename):
|
||||||
if approveHandle not in open(approvedFilename).read():
|
if approveHandle not in open(approvedFilename).read():
|
||||||
approvedFile = open(approvedFilename, "a+")
|
with open(approvedFilename, 'a+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
approvedFile.close()
|
|
||||||
else:
|
else:
|
||||||
approvedFile = open(approvedFilename, "w+")
|
with open(approvedFilename, 'w+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
approvedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def manualApproveFollowRequest(session, baseDir: str,
|
def manualApproveFollowRequest(session, baseDir: str,
|
||||||
|
|
@ -131,7 +128,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
'" ' + approveFollowsFilename)
|
'" ' + approveFollowsFilename)
|
||||||
return
|
return
|
||||||
|
|
||||||
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
with open(approveFollowsFilename + '.new', 'w+') as approvefilenew:
|
||||||
updateApprovedFollowers = False
|
updateApprovedFollowers = False
|
||||||
followActivityfilename = None
|
followActivityfilename = None
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
|
|
@ -139,7 +136,9 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
# is this the approved follow?
|
# is this the approved follow?
|
||||||
if handleOfFollowRequester.startswith(approveHandleFull):
|
if handleOfFollowRequester.startswith(approveHandleFull):
|
||||||
handleOfFollowRequester = \
|
handleOfFollowRequester = \
|
||||||
handleOfFollowRequester.replace('\n', '').replace('\r', '')
|
handleOfFollowRequester.replace('\n', '')
|
||||||
|
handleOfFollowRequester = \
|
||||||
|
handleOfFollowRequester.replace('\r', '')
|
||||||
port2 = port
|
port2 = port
|
||||||
if ':' in handleOfFollowRequester:
|
if ':' in handleOfFollowRequester:
|
||||||
port2Str = handleOfFollowRequester.split(':')[1]
|
port2Str = handleOfFollowRequester.split(':')[1]
|
||||||
|
|
@ -154,7 +153,9 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
approveNickname = approveHandle.split('@')[0]
|
approveNickname = approveHandle.split('@')[0]
|
||||||
approveDomain = approveHandle.split('@')[1]
|
approveDomain = approveHandle.split('@')[1]
|
||||||
approveDomain = \
|
approveDomain = \
|
||||||
approveDomain.replace('\n', '').replace('\r', '')
|
approveDomain.replace('\n', '')
|
||||||
|
approveDomain = \
|
||||||
|
approveDomain.replace('\r', '')
|
||||||
approvePort = port2
|
approvePort = port2
|
||||||
if ':' in approveDomain:
|
if ':' in approveDomain:
|
||||||
approvePort = approveDomain.split(':')[1]
|
approvePort = approveDomain.split(':')[1]
|
||||||
|
|
@ -162,22 +163,25 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
print('Manual follow accept: Sending Accept for ' +
|
print('Manual follow accept: Sending Accept for ' +
|
||||||
handle + ' follow request from ' +
|
handle + ' follow request from ' +
|
||||||
approveNickname + '@' + approveDomain)
|
approveNickname + '@' + approveDomain)
|
||||||
followedAccountAccepts(session, baseDir, httpPrefix,
|
followedAccountAccepts(session, baseDir,
|
||||||
|
httpPrefix,
|
||||||
nickname, domain, port,
|
nickname, domain, port,
|
||||||
approveNickname, approveDomain,
|
approveNickname,
|
||||||
|
approveDomain,
|
||||||
approvePort,
|
approvePort,
|
||||||
followJson['actor'],
|
followJson['actor'],
|
||||||
federationList,
|
federationList,
|
||||||
followJson,
|
followJson,
|
||||||
sendThreads, postLog,
|
sendThreads, postLog,
|
||||||
cachedWebfingers, personCache,
|
cachedWebfingers,
|
||||||
debug, projectVersion, False)
|
personCache,
|
||||||
|
debug,
|
||||||
|
projectVersion, False)
|
||||||
updateApprovedFollowers = True
|
updateApprovedFollowers = True
|
||||||
else:
|
else:
|
||||||
# this isn't the approved follow so it will remain
|
# this isn't the approved follow so it will remain
|
||||||
# in the requests file
|
# in the requests file
|
||||||
approvefilenew.write(handleOfFollowRequester)
|
approvefilenew.write(handleOfFollowRequester)
|
||||||
approvefilenew.close()
|
|
||||||
|
|
||||||
followersFilename = accountDir + '/followers.txt'
|
followersFilename = accountDir + '/followers.txt'
|
||||||
if updateApprovedFollowers:
|
if updateApprovedFollowers:
|
||||||
|
|
@ -201,9 +205,8 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
else:
|
else:
|
||||||
print('Manual follow accept: first follower accepted for ' +
|
print('Manual follow accept: first follower accepted for ' +
|
||||||
handle + ' is ' + approveHandleFull)
|
handle + ' is ' + approveHandleFull)
|
||||||
followersFile = open(followersFilename, "w+")
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandleFull + '\n')
|
followersFile.write(approveHandleFull + '\n')
|
||||||
followersFile.close()
|
|
||||||
|
|
||||||
# only update the follow requests file if the follow is confirmed to be
|
# only update the follow requests file if the follow is confirmed to be
|
||||||
# in followers.txt
|
# in followers.txt
|
||||||
|
|
|
||||||
|
|
@ -55,19 +55,15 @@ def _updateFeedsOutboxIndex(baseDir: str, domain: str, postId: str) -> None:
|
||||||
print('WARN: Failed to write entry to feeds posts index ' +
|
print('WARN: Failed to write entry to feeds posts index ' +
|
||||||
indexFilename + ' ' + str(e))
|
indexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
feedsFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as feedsFile:
|
||||||
if feedsFile:
|
|
||||||
feedsFile.write(postId + '\n')
|
feedsFile.write(postId + '\n')
|
||||||
feedsFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
||||||
"""Saves the time when an rss post arrived to a file
|
"""Saves the time when an rss post arrived to a file
|
||||||
"""
|
"""
|
||||||
arrivedFile = open(postFilename + '.arrived', 'w+')
|
with open(postFilename + '.arrived', 'w+') as arrivedFile:
|
||||||
if arrivedFile:
|
|
||||||
arrivedFile.write(arrived)
|
arrivedFile.write(arrived)
|
||||||
arrivedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _removeControlCharacters(content: str) -> str:
|
def _removeControlCharacters(content: str) -> str:
|
||||||
|
|
@ -435,15 +431,11 @@ def _createNewsMirror(baseDir: str, domain: str,
|
||||||
|
|
||||||
# append the post Id number to the index file
|
# append the post Id number to the index file
|
||||||
if os.path.isfile(mirrorIndexFilename):
|
if os.path.isfile(mirrorIndexFilename):
|
||||||
indexFile = open(mirrorIndexFilename, "a+")
|
with open(mirrorIndexFilename, 'a+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
indexFile.close()
|
|
||||||
else:
|
else:
|
||||||
indexFile = open(mirrorIndexFilename, "w+")
|
with open(mirrorIndexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
indexFile.close()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
31
person.py
31
person.py
|
|
@ -131,7 +131,7 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
|
||||||
personJson[iconFilenameBase]['mediaType'] = mediaType
|
personJson[iconFilenameBase]['mediaType'] = mediaType
|
||||||
personJson[iconFilenameBase]['url'] = \
|
personJson[iconFilenameBase]['url'] = \
|
||||||
httpPrefix + '://' + fullDomain + '/users/' + \
|
httpPrefix + '://' + fullDomain + '/users/' + \
|
||||||
nickname + '/'+iconFilename
|
nickname + '/' + iconFilename
|
||||||
saveJson(personJson, personFilename)
|
saveJson(personJson, personFilename)
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
|
|
@ -879,13 +879,13 @@ def reenableAccount(baseDir: str, nickname: str) -> None:
|
||||||
"""
|
"""
|
||||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||||
if os.path.isfile(suspendedFilename):
|
if os.path.isfile(suspendedFilename):
|
||||||
|
lines = []
|
||||||
with open(suspendedFilename, "r") as f:
|
with open(suspendedFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
suspendedFile = open(suspendedFilename, "w+")
|
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n').strip('\r') != nickname:
|
if suspended.strip('\n').strip('\r') != nickname:
|
||||||
suspendedFile.write(suspended)
|
suspendedFile.write(suspended)
|
||||||
suspendedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
|
@ -923,15 +923,11 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n').strip('\r') == nickname:
|
if suspended.strip('\n').strip('\r') == nickname:
|
||||||
return
|
return
|
||||||
suspendedFile = open(suspendedFilename, 'a+')
|
with open(suspendedFilename, 'a+') as suspendedFile:
|
||||||
if suspendedFile:
|
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
suspendedFile.close()
|
|
||||||
else:
|
else:
|
||||||
suspendedFile = open(suspendedFilename, 'w+')
|
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||||
if suspendedFile:
|
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
suspendedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def canRemovePost(baseDir: str, nickname: str,
|
def canRemovePost(baseDir: str, nickname: str,
|
||||||
|
|
@ -983,14 +979,13 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
||||||
continue
|
continue
|
||||||
if matchStr not in open(tagFilename).read():
|
if matchStr not in open(tagFilename).read():
|
||||||
continue
|
continue
|
||||||
|
lines = []
|
||||||
with open(tagFilename, "r") as f:
|
with open(tagFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
tagFile = open(tagFilename, "w+")
|
with open(tagFilename, 'w+') as tagFile:
|
||||||
if tagFile:
|
|
||||||
for tagline in lines:
|
for tagline in lines:
|
||||||
if matchStr not in tagline:
|
if matchStr not in tagline:
|
||||||
tagFile.write(tagline)
|
tagFile.write(tagline)
|
||||||
tagFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def removeAccount(baseDir: str, nickname: str,
|
def removeAccount(baseDir: str, nickname: str,
|
||||||
|
|
@ -1132,10 +1127,8 @@ def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'r') as snoozedFile:
|
with open(snoozedFilename, 'r') as snoozedFile:
|
||||||
content = snoozedFile.read().replace(replaceStr, '')
|
content = snoozedFile.read().replace(replaceStr, '')
|
||||||
if content:
|
if content:
|
||||||
writeSnoozedFile = open(snoozedFilename, 'w+')
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
if writeSnoozedFile:
|
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
writeSnoozedFile.close()
|
|
||||||
|
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return True
|
return True
|
||||||
|
|
@ -1154,11 +1147,9 @@ def personSnooze(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(snoozedFilename):
|
if os.path.isfile(snoozedFilename):
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return
|
return
|
||||||
snoozedFile = open(snoozedFilename, "a+")
|
with open(snoozedFilename, 'a+') as snoozedFile:
|
||||||
if snoozedFile:
|
|
||||||
snoozedFile.write(snoozeActor + ' ' +
|
snoozedFile.write(snoozeActor + ' ' +
|
||||||
str(int(time.time())) + '\n')
|
str(int(time.time())) + '\n')
|
||||||
snoozedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1185,10 +1176,8 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'r') as snoozedFile:
|
with open(snoozedFilename, 'r') as snoozedFile:
|
||||||
content = snoozedFile.read().replace(replaceStr, '')
|
content = snoozedFile.read().replace(replaceStr, '')
|
||||||
if content:
|
if content:
|
||||||
writeSnoozedFile = open(snoozedFilename, 'w+')
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
if writeSnoozedFile:
|
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
writeSnoozedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
|
||||||
36
posts.py
36
posts.py
|
|
@ -728,10 +728,8 @@ def _updateHashtagsIndex(baseDir: str, tag: {}, newPostId: str) -> None:
|
||||||
|
|
||||||
if not os.path.isfile(tagsFilename):
|
if not os.path.isfile(tagsFilename):
|
||||||
# create a new tags index file
|
# create a new tags index file
|
||||||
tagsFile = open(tagsFilename, "w+")
|
with open(tagsFilename, 'w+') as tagsFile:
|
||||||
if tagsFile:
|
|
||||||
tagsFile.write(tagline)
|
tagsFile.write(tagline)
|
||||||
tagsFile.close()
|
|
||||||
else:
|
else:
|
||||||
# prepend to tags index file
|
# prepend to tags index file
|
||||||
if tagline not in open(tagsFilename).read():
|
if tagline not in open(tagsFilename).read():
|
||||||
|
|
@ -767,10 +765,8 @@ def _addSchedulePost(baseDir: str, nickname: str, domain: str,
|
||||||
print('WARN: Failed to write entry to scheduled posts index ' +
|
print('WARN: Failed to write entry to scheduled posts index ' +
|
||||||
scheduleIndexFilename + ' ' + str(e))
|
scheduleIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
scheduleFile = open(scheduleIndexFilename, 'w+')
|
with open(scheduleIndexFilename, 'w+') as scheduleFile:
|
||||||
if scheduleFile:
|
|
||||||
scheduleFile.write(indexStr + '\n')
|
scheduleFile.write(indexStr + '\n')
|
||||||
scheduleFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _appendEventFields(newPost: {},
|
def _appendEventFields(newPost: {},
|
||||||
|
|
@ -1064,7 +1060,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix + '://' + domain + '/users/' + nickname + \
|
httpPrefix + '://' + domain + '/users/' + nickname + \
|
||||||
'/statuses/' + statusNumber + '/replies'
|
'/statuses/' + statusNumber + '/replies'
|
||||||
newPostUrl = \
|
newPostUrl = \
|
||||||
httpPrefix + '://' + domain + '/@' + nickname + '/'+statusNumber
|
httpPrefix + '://' + domain + '/@' + nickname + '/' + statusNumber
|
||||||
newPostAttributedTo = \
|
newPostAttributedTo = \
|
||||||
httpPrefix + '://' + domain + '/users/' + nickname
|
httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
newPost = {
|
newPost = {
|
||||||
|
|
@ -1124,7 +1120,7 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix + '://' + domain + '/users/' + nickname + \
|
httpPrefix + '://' + domain + '/users/' + nickname + \
|
||||||
'/statuses/' + statusNumber + '/replies'
|
'/statuses/' + statusNumber + '/replies'
|
||||||
newPostUrl = \
|
newPostUrl = \
|
||||||
httpPrefix + '://' + domain + '/@' + nickname+'/' + statusNumber
|
httpPrefix + '://' + domain + '/@' + nickname + '/' + statusNumber
|
||||||
newPost = {
|
newPost = {
|
||||||
"@context": postContext,
|
"@context": postContext,
|
||||||
'id': newPostId,
|
'id': newPostId,
|
||||||
|
|
@ -1194,10 +1190,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
newPost['moderationStatus'] = 'pending'
|
newPost['moderationStatus'] = 'pending'
|
||||||
# save to index file
|
# save to index file
|
||||||
moderationIndexFile = baseDir + '/accounts/moderation.txt'
|
moderationIndexFile = baseDir + '/accounts/moderation.txt'
|
||||||
modFile = open(moderationIndexFile, "a+")
|
with open(moderationIndexFile, 'a+') as modFile:
|
||||||
if modFile:
|
|
||||||
modFile.write(newPostId + '\n')
|
modFile.write(newPostId + '\n')
|
||||||
modFile.close()
|
|
||||||
|
|
||||||
# If a patch has been posted - i.e. the output from
|
# If a patch has been posted - i.e. the output from
|
||||||
# git format-patch - then convert the activitypub type
|
# git format-patch - then convert the activitypub type
|
||||||
|
|
@ -1305,10 +1299,8 @@ def pinPost(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
pinFile = open(pinnedFilename, "w+")
|
with open(pinnedFilename, 'w+') as pinFile:
|
||||||
if pinFile:
|
|
||||||
pinFile.write(pinnedContent)
|
pinFile.write(pinnedContent)
|
||||||
pinFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
|
@ -2904,7 +2896,7 @@ def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
pageNumber = 1
|
pageNumber = 1
|
||||||
|
|
||||||
pageStr = '?page=' + str(pageNumber)
|
pageStr = '?page=' + str(pageNumber)
|
||||||
boxUrl = httpPrefix+'://'+domain+'/users/'+nickname+'/'+boxname
|
boxUrl = httpPrefix + '://' + domain + '/users/' + nickname + '/' + boxname
|
||||||
boxHeader = {
|
boxHeader = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
'first': boxUrl + '?page=true',
|
'first': boxUrl + '?page=true',
|
||||||
|
|
@ -3452,10 +3444,8 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
||||||
break
|
break
|
||||||
# save the new index file
|
# save the new index file
|
||||||
if len(newIndex) > 0:
|
if len(newIndex) > 0:
|
||||||
indexFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(newIndex)
|
indexFile.write(newIndex)
|
||||||
indexFile.close()
|
|
||||||
|
|
||||||
postsInBoxDict = {}
|
postsInBoxDict = {}
|
||||||
postsCtr = 0
|
postsCtr = 0
|
||||||
|
|
@ -3859,8 +3849,8 @@ def populateRepliesJson(baseDir: str, nickname: str, domain: str,
|
||||||
searchFilename = \
|
searchFilename = \
|
||||||
baseDir + \
|
baseDir + \
|
||||||
'/accounts/' + nickname + '@' + \
|
'/accounts/' + nickname + '@' + \
|
||||||
domain+'/' + \
|
domain + '/' + \
|
||||||
boxname+'/' + \
|
boxname + '/' + \
|
||||||
messageId2.replace('/', '#') + '.json'
|
messageId2.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
if authorized or \
|
if authorized or \
|
||||||
|
|
@ -3887,7 +3877,7 @@ def populateRepliesJson(baseDir: str, nickname: str, domain: str,
|
||||||
searchFilename = \
|
searchFilename = \
|
||||||
baseDir + \
|
baseDir + \
|
||||||
'/accounts/inbox@' + \
|
'/accounts/inbox@' + \
|
||||||
domain+'/inbox/' + \
|
domain + '/inbox/' + \
|
||||||
messageId2.replace('/', '#') + '.json'
|
messageId2.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
if authorized or \
|
if authorized or \
|
||||||
|
|
@ -3919,10 +3909,8 @@ def _rejectAnnounce(announceFilename: str,
|
||||||
|
|
||||||
# reject the post referenced by the announce activity object
|
# reject the post referenced by the announce activity object
|
||||||
if not os.path.isfile(announceFilename + '.reject'):
|
if not os.path.isfile(announceFilename + '.reject'):
|
||||||
rejectAnnounceFile = open(announceFilename + '.reject', "w+")
|
with open(announceFilename + '.reject', 'w+') as rejectAnnounceFile:
|
||||||
if rejectAnnounceFile:
|
|
||||||
rejectAnnounceFile.write('\n')
|
rejectAnnounceFile.write('\n')
|
||||||
rejectAnnounceFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
||||||
|
|
|
||||||
|
|
@ -67,21 +67,17 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
||||||
votersFilename = questionPostFilename.replace('.json', '.voters')
|
votersFilename = questionPostFilename.replace('.json', '.voters')
|
||||||
if not os.path.isfile(votersFilename):
|
if not os.path.isfile(votersFilename):
|
||||||
# create a new voters file
|
# create a new voters file
|
||||||
votersFile = open(votersFilename, 'w+')
|
with open(votersFilename, 'w+') as votersFile:
|
||||||
if votersFile:
|
|
||||||
votersFile.write(replyJson['actor'] +
|
votersFile.write(replyJson['actor'] +
|
||||||
votersFileSeparator +
|
votersFileSeparator +
|
||||||
foundAnswer + '\n')
|
foundAnswer + '\n')
|
||||||
votersFile.close()
|
|
||||||
else:
|
else:
|
||||||
if replyJson['actor'] not in open(votersFilename).read():
|
if replyJson['actor'] not in open(votersFilename).read():
|
||||||
# append to the voters file
|
# append to the voters file
|
||||||
votersFile = open(votersFilename, "a+")
|
with open(votersFilename, 'a+') as votersFile:
|
||||||
if votersFile:
|
|
||||||
votersFile.write(replyJson['actor'] +
|
votersFile.write(replyJson['actor'] +
|
||||||
votersFileSeparator +
|
votersFileSeparator +
|
||||||
foundAnswer + '\n')
|
foundAnswer + '\n')
|
||||||
votersFile.close()
|
|
||||||
else:
|
else:
|
||||||
# change an entry in the voters file
|
# change an entry in the voters file
|
||||||
with open(votersFilename, "r") as votersFile:
|
with open(votersFilename, "r") as votersFile:
|
||||||
|
|
|
||||||
|
|
@ -129,11 +129,9 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
# write the new schedule index file
|
# write the new schedule index file
|
||||||
scheduleIndexFile = \
|
scheduleIndexFile = \
|
||||||
baseDir + '/accounts/' + handle + '/schedule.index'
|
baseDir + '/accounts/' + handle + '/schedule.index'
|
||||||
scheduleFile = open(scheduleIndexFile, "w+")
|
with open(scheduleIndexFile, 'w+') as scheduleFile:
|
||||||
if scheduleFile:
|
|
||||||
for line in indexLines:
|
for line in indexLines:
|
||||||
scheduleFile.write(line)
|
scheduleFile.write(line)
|
||||||
scheduleFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
|
def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
|
||||||
|
|
|
||||||
10
shares.py
10
shares.py
|
|
@ -264,8 +264,8 @@ def getSharesFeedForPerson(baseDir: str,
|
||||||
idStr = httpPrefix + '://' + domain + '/users/' + nickname
|
idStr = httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
shares = {
|
shares = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
'first': idStr+'/shares?page=1',
|
'first': idStr + '/shares?page=1',
|
||||||
'id': idStr+'/shares',
|
'id': idStr + '/shares',
|
||||||
'totalItems': str(noOfShares),
|
'totalItems': str(noOfShares),
|
||||||
'type': 'OrderedCollection'
|
'type': 'OrderedCollection'
|
||||||
}
|
}
|
||||||
|
|
@ -278,9 +278,9 @@ def getSharesFeedForPerson(baseDir: str,
|
||||||
idStr = httpPrefix + '://' + domain + '/users/' + nickname
|
idStr = httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
shares = {
|
shares = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
'id': idStr+'/shares?page='+str(pageNumber),
|
'id': idStr + '/shares?page=' + str(pageNumber),
|
||||||
'orderedItems': [],
|
'orderedItems': [],
|
||||||
'partOf': idStr+'/shares',
|
'partOf': idStr + '/shares',
|
||||||
'totalItems': 0,
|
'totalItems': 0,
|
||||||
'type': 'OrderedCollectionPage'
|
'type': 'OrderedCollectionPage'
|
||||||
}
|
}
|
||||||
|
|
@ -339,7 +339,7 @@ def sendShareViaServer(baseDir, session,
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Add',
|
'type': 'Add',
|
||||||
'actor': actor,
|
'actor': actor,
|
||||||
'target': actor+'/shares',
|
'target': actor + '/shares',
|
||||||
'object': {
|
'object': {
|
||||||
"type": "Offer",
|
"type": "Offer",
|
||||||
"displayName": displayName,
|
"displayName": displayName,
|
||||||
|
|
|
||||||
8
tests.py
8
tests.py
|
|
@ -2045,7 +2045,7 @@ def _testAddEmoji():
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
content = contentModified
|
content = contentModified
|
||||||
contentModified = replaceEmojiFromTags(content, tags, 'content')
|
contentModified = replaceEmojiFromTags(content, tags, 'content')
|
||||||
# print('contentModified: '+contentModified)
|
# print('contentModified: ' + contentModified)
|
||||||
assert contentModified == '<p>Emoji 🍋 🍓 🍌</p>'
|
assert contentModified == '<p>Emoji 🍋 🍓 🍌</p>'
|
||||||
|
|
||||||
os.chdir(baseDirOriginal)
|
os.chdir(baseDirOriginal)
|
||||||
|
|
@ -2124,7 +2124,7 @@ def _testRecentPostsCache():
|
||||||
htmlStr = '<html></html>'
|
htmlStr = '<html></html>'
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
postJsonObject = {
|
postJsonObject = {
|
||||||
"id": "https://somesite.whatever/users/someuser/statuses/"+str(i)
|
"id": "https://somesite.whatever/users/someuser/statuses/" + str(i)
|
||||||
}
|
}
|
||||||
updateRecentPostsCache(recentPostsCache, maxRecentPosts,
|
updateRecentPostsCache(recentPostsCache, maxRecentPosts,
|
||||||
postJsonObject, htmlStr)
|
postJsonObject, htmlStr)
|
||||||
|
|
@ -3883,10 +3883,8 @@ def _testSpoofGeolocation() -> None:
|
||||||
|
|
||||||
kmlStr += '</Document>\n'
|
kmlStr += '</Document>\n'
|
||||||
kmlStr += '</kml>'
|
kmlStr += '</kml>'
|
||||||
kmlFile = open('unittest_decoy.kml', 'w+')
|
with open('unittest_decoy.kml', 'w+') as kmlFile:
|
||||||
if kmlFile:
|
|
||||||
kmlFile.write(kmlStr)
|
kmlFile.write(kmlStr)
|
||||||
kmlFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _testSkills() -> None:
|
def _testSkills() -> None:
|
||||||
|
|
|
||||||
5
theme.py
5
theme.py
|
|
@ -808,9 +808,6 @@ def updateDefaultThemesList(baseDir: str) -> None:
|
||||||
"""
|
"""
|
||||||
themeNames = getThemesList(baseDir)
|
themeNames = getThemesList(baseDir)
|
||||||
defaultThemesFilename = baseDir + '/defaultthemes.txt'
|
defaultThemesFilename = baseDir + '/defaultthemes.txt'
|
||||||
defaultThemesFile = open(defaultThemesFilename, "w+")
|
with open(defaultThemesFilename, 'w+') as defaultThemesFile:
|
||||||
if not defaultThemesFile:
|
|
||||||
return
|
|
||||||
for name in themeNames:
|
for name in themeNames:
|
||||||
defaultThemesFile.write(name + '\n')
|
defaultThemesFile.write(name + '\n')
|
||||||
defaultThemesFile.close()
|
|
||||||
|
|
|
||||||
13
utils.py
13
utils.py
|
|
@ -43,9 +43,8 @@ def refreshNewswire(baseDir: str):
|
||||||
refreshNewswireFilename = baseDir + '/accounts/.refresh_newswire'
|
refreshNewswireFilename = baseDir + '/accounts/.refresh_newswire'
|
||||||
if os.path.isfile(refreshNewswireFilename):
|
if os.path.isfile(refreshNewswireFilename):
|
||||||
return
|
return
|
||||||
refreshFile = open(refreshNewswireFilename, 'w+')
|
with open(refreshNewswireFilename, 'w+') as refreshFile:
|
||||||
refreshFile.write('\n')
|
refreshFile.write('\n')
|
||||||
refreshFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def getSHA256(msg: str):
|
def getSHA256(msg: str):
|
||||||
|
|
@ -1564,10 +1563,10 @@ def getCachedPostFilename(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
cachedPostDir = getCachedPostDirectory(baseDir, nickname, domain)
|
cachedPostDir = getCachedPostDirectory(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(cachedPostDir):
|
if not os.path.isdir(cachedPostDir):
|
||||||
# print('ERROR: invalid html cache directory '+cachedPostDir)
|
# print('ERROR: invalid html cache directory ' + cachedPostDir)
|
||||||
return None
|
return None
|
||||||
if '@' not in cachedPostDir:
|
if '@' not in cachedPostDir:
|
||||||
# print('ERROR: invalid html cache directory '+cachedPostDir)
|
# print('ERROR: invalid html cache directory ' + cachedPostDir)
|
||||||
return None
|
return None
|
||||||
cachedPostId = removeIdEnding(postJsonObject['id'])
|
cachedPostId = removeIdEnding(postJsonObject['id'])
|
||||||
cachedPostFilename = cachedPostDir + '/' + cachedPostId.replace('/', '#')
|
cachedPostFilename = cachedPostDir + '/' + cachedPostId.replace('/', '#')
|
||||||
|
|
@ -1867,7 +1866,7 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
if debug:
|
if debug:
|
||||||
pprint(postJsonObject)
|
pprint(postJsonObject)
|
||||||
print('DEBUG: post '+objectUrl+' has no object')
|
print('DEBUG: post ' + objectUrl + ' has no object')
|
||||||
return
|
return
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
return
|
return
|
||||||
|
|
@ -2198,10 +2197,8 @@ def rejectPostId(baseDir: str, nickname: str, domain: str,
|
||||||
if recentPostsCache['html'].get(postUrl):
|
if recentPostsCache['html'].get(postUrl):
|
||||||
del recentPostsCache['html'][postUrl]
|
del recentPostsCache['html'][postUrl]
|
||||||
|
|
||||||
rejectFile = open(postFilename + '.reject', "w+")
|
with open(postFilename + '.reject', 'w+') as rejectFile:
|
||||||
if rejectFile:
|
|
||||||
rejectFile.write('\n')
|
rejectFile.write('\n')
|
||||||
rejectFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def isDM(postJsonObject: {}) -> bool:
|
def isDM(postJsonObject: {}) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
tlStr += \
|
tlStr += \
|
||||||
'<a href="' + usersPath + \
|
'<a href="' + usersPath + \
|
||||||
'/inbox" tabindex="-1"><button class="' + \
|
'/inbox" tabindex="-1"><button class="' + \
|
||||||
inboxButton+'"><span>' + translate['Inbox'] + \
|
inboxButton + '"><span>' + translate['Inbox'] + \
|
||||||
'</span></button></a>'
|
'</span></button></a>'
|
||||||
|
|
||||||
if not featuresHeader:
|
if not featuresHeader:
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def _saveIndividualPostAsHtmlToCache(baseDir: str,
|
||||||
fp.write(postHtml)
|
fp.write(postHtml)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: saving post to cache ' + str(e))
|
print('ERROR: saving post to cache, ' + str(e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1332,10 +1332,8 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, postJsonObject['actor'],
|
translate, postJsonObject['actor'],
|
||||||
themeName)
|
themeName)
|
||||||
ttsFile = open(announceFilename + '.tts', "w+")
|
with open(announceFilename + '.tts', 'w+') as ttsFile:
|
||||||
if ttsFile:
|
|
||||||
ttsFile.write('\n')
|
ttsFile.write('\n')
|
||||||
ttsFile.close()
|
|
||||||
|
|
||||||
isAnnounced = True
|
isAnnounced = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -534,7 +534,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
if xmppAddress:
|
if xmppAddress:
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p>' + translate['XMPP'] + ': <a href="xmpp:' + \
|
'<p>' + translate['XMPP'] + ': <a href="xmpp:' + \
|
||||||
xmppAddress + '">'+xmppAddress + '</a></p>\n'
|
xmppAddress + '">' + xmppAddress + '</a></p>\n'
|
||||||
if matrixAddress:
|
if matrixAddress:
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p>' + translate['Matrix'] + ': ' + matrixAddress + '</p>\n'
|
'<p>' + translate['Matrix'] + ': ' + matrixAddress + '</p>\n'
|
||||||
|
|
@ -1675,7 +1675,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
translate['Matrix'] + '</label><br>\n'
|
translate['Matrix'] + '</label><br>\n'
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
' <input type="text" name="matrixAddress" value="' + \
|
' <input type="text" name="matrixAddress" value="' + \
|
||||||
matrixAddress+'">\n'
|
matrixAddress + '">\n'
|
||||||
|
|
||||||
editProfileForm += '<label class="labels">SSB</label><br>\n'
|
editProfileForm += '<label class="labels">SSB</label><br>\n'
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
|
|
|
||||||
|
|
@ -1242,7 +1242,7 @@ def getPostAttachmentsAsHtml(postJsonObject: {}, boxName: str, translate: {},
|
||||||
galleryStr += \
|
galleryStr += \
|
||||||
' ' + replyStr + announceStr + \
|
' ' + replyStr + announceStr + \
|
||||||
likeStr + bookmarkStr + \
|
likeStr + bookmarkStr + \
|
||||||
deleteStr + muteStr+'\n'
|
deleteStr + muteStr + '\n'
|
||||||
galleryStr += ' </div>\n'
|
galleryStr += ' </div>\n'
|
||||||
galleryStr += ' <div class="mediaavatar">\n'
|
galleryStr += ' <div class="mediaavatar">\n'
|
||||||
galleryStr += ' ' + avatarLink + '\n'
|
galleryStr += ' ' + avatarLink + '\n'
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,8 @@ def welcomeScreenIsComplete(baseDir: str,
|
||||||
if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
return
|
return
|
||||||
completeFilename = accountPath + '/.welcome_complete'
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
completeFile = open(completeFilename, 'w+')
|
with open(completeFilename, 'w+') as completeFile:
|
||||||
if completeFile:
|
|
||||||
completeFile.write('\n')
|
completeFile.write('\n')
|
||||||
completeFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def htmlWelcomeScreen(baseDir: str, nickname: str,
|
def htmlWelcomeScreen(baseDir: str, nickname: str,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue