mirror of https://gitlab.com/bashrc2/epicyon
Function for account directory
parent
53f6b637bf
commit
e4b9a27de0
|
@ -16,6 +16,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import domainPermitted
|
from utils import domainPermitted
|
||||||
from utils import followPerson
|
from utils import followPerson
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _createAcceptReject(baseDir: str, federationList: [],
|
def _createAcceptReject(baseDir: str, federationList: [],
|
||||||
|
@ -147,8 +148,8 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
acceptedDomainFull = acceptedDomain + ':' + str(acceptedPort)
|
acceptedDomainFull = acceptedDomain + ':' + str(acceptedPort)
|
||||||
|
|
||||||
# has this person already been unfollowed?
|
# has this person already been unfollowed?
|
||||||
unfollowedFilename = baseDir + '/accounts/' + \
|
unfollowedFilename = \
|
||||||
nickname + '@' + acceptedDomainFull + '/unfollowed.txt'
|
acctDir(baseDir, nickname, acceptedDomainFull) + '/unfollowed.txt'
|
||||||
if os.path.isfile(unfollowedFilename):
|
if os.path.isfile(unfollowedFilename):
|
||||||
if followedNickname + '@' + followedDomainFull in \
|
if followedNickname + '@' + followedDomainFull in \
|
||||||
open(unfollowedFilename).read():
|
open(unfollowedFilename).read():
|
||||||
|
|
|
@ -17,6 +17,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def setAvailability(baseDir: str, nickname: str, domain: str,
|
def setAvailability(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -26,7 +27,7 @@ def setAvailability(baseDir: str, nickname: str, domain: str,
|
||||||
# avoid giant strings
|
# avoid giant strings
|
||||||
if len(status) > 128:
|
if len(status) > 128:
|
||||||
return False
|
return False
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
|
@ -39,7 +40,7 @@ def setAvailability(baseDir: str, nickname: str, domain: str,
|
||||||
def getAvailability(baseDir: str, nickname: str, domain: str) -> str:
|
def getAvailability(baseDir: str, nickname: str, domain: str) -> str:
|
||||||
"""Returns the availability for a given person
|
"""Returns the availability for a given person
|
||||||
"""
|
"""
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
|
|
|
@ -27,6 +27,7 @@ from utils import locatePost
|
||||||
from utils import evilIncarnate
|
from utils import evilIncarnate
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def addGlobalBlock(baseDir: str,
|
def addGlobalBlock(baseDir: str,
|
||||||
|
@ -60,8 +61,7 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
"""Block the given account
|
"""Block the given account
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
blockingFilename = baseDir + '/accounts/' + \
|
blockingFilename = acctDir(baseDir, nickname, domain) + '/blocking.txt'
|
||||||
nickname + '@' + domain + '/blocking.txt'
|
|
||||||
blockHandle = blockNickname + '@' + blockDomain
|
blockHandle = blockNickname + '@' + blockDomain
|
||||||
if os.path.isfile(blockingFilename):
|
if os.path.isfile(blockingFilename):
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
|
@ -112,8 +112,7 @@ def removeBlock(baseDir: str, nickname: str, domain: str,
|
||||||
"""Unblock the given account
|
"""Unblock the given account
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
unblockingFilename = baseDir + '/accounts/' + \
|
unblockingFilename = acctDir(baseDir, nickname, domain) + '/blocking.txt'
|
||||||
nickname + '@' + domain + '/blocking.txt'
|
|
||||||
unblockHandle = unblockNickname + '@' + unblockDomain
|
unblockHandle = unblockNickname + '@' + unblockDomain
|
||||||
if os.path.isfile(unblockingFilename):
|
if os.path.isfile(unblockingFilename):
|
||||||
if unblockHandle in open(unblockingFilename).read():
|
if unblockHandle in open(unblockingFilename).read():
|
||||||
|
@ -287,7 +286,7 @@ def isBlocked(baseDir: str, nickname: str, domain: str,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# account level allow list
|
# account level allow list
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
allowFilename = accountDir + '/allowedinstances.txt'
|
allowFilename = accountDir + '/allowedinstances.txt'
|
||||||
if os.path.isfile(allowFilename):
|
if os.path.isfile(allowFilename):
|
||||||
if blockDomain not in open(allowFilename).read():
|
if blockDomain not in open(allowFilename).read():
|
||||||
|
|
35
blog.py
35
blog.py
|
@ -27,6 +27,7 @@ from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
from utils import getActorPropertyUrl
|
from utils import getActorPropertyUrl
|
||||||
|
from utils import acctDir
|
||||||
from posts import createBlogsTimeline
|
from posts import createBlogsTimeline
|
||||||
from newswire import rss2Header
|
from newswire import rss2Header
|
||||||
from newswire import rss2Footer
|
from newswire import rss2Footer
|
||||||
|
@ -46,8 +47,8 @@ def _noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
tryPostBox = ('tlblogs', 'inbox', 'outbox')
|
tryPostBox = ('tlblogs', 'inbox', 'outbox')
|
||||||
boxFound = False
|
boxFound = False
|
||||||
for postBox in tryPostBox:
|
for postBox in tryPostBox:
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = \
|
||||||
nickname + '@' + domain + '/' + postBox + '/' + \
|
acctDir(baseDir, nickname, domain) + '/' + postBox + '/' + \
|
||||||
postId.replace('/', '#') + '.replies'
|
postId.replace('/', '#') + '.replies'
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
boxFound = True
|
boxFound = True
|
||||||
|
@ -55,8 +56,8 @@ def _noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
if not boxFound:
|
if not boxFound:
|
||||||
# post may exist but has no replies
|
# post may exist but has no replies
|
||||||
for postBox in tryPostBox:
|
for postBox in tryPostBox:
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = \
|
||||||
nickname + '@' + domain + '/' + postBox + '/' + \
|
acctDir(baseDir, nickname, domain) + '/' + postBox + '/' + \
|
||||||
postId.replace('/', '#')
|
postId.replace('/', '#')
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
return 1
|
return 1
|
||||||
|
@ -106,8 +107,8 @@ def _getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
tryPostBox = ('tlblogs', 'inbox', 'outbox')
|
tryPostBox = ('tlblogs', 'inbox', 'outbox')
|
||||||
boxFound = False
|
boxFound = False
|
||||||
for postBox in tryPostBox:
|
for postBox in tryPostBox:
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = \
|
||||||
nickname + '@' + domain + '/' + postBox + '/' + \
|
acctDir(baseDir, nickname, domain) + '/' + postBox + '/' + \
|
||||||
postId.replace('/', '#') + '.replies'
|
postId.replace('/', '#') + '.replies'
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
boxFound = True
|
boxFound = True
|
||||||
|
@ -115,12 +116,11 @@ def _getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
if not boxFound:
|
if not boxFound:
|
||||||
# post may exist but has no replies
|
# post may exist but has no replies
|
||||||
for postBox in tryPostBox:
|
for postBox in tryPostBox:
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = \
|
||||||
nickname + '@' + domain + '/' + postBox + '/' + \
|
acctDir(baseDir, nickname, domain) + '/' + postBox + '/' + \
|
||||||
postId.replace('/', '#') + '.json'
|
postId.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/postcache/' + \
|
'/postcache/' + \
|
||||||
postId.replace('/', '#') + '.html'
|
postId.replace('/', '#') + '.html'
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
|
@ -135,8 +135,7 @@ def _getBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
||||||
replyPostId = replyPostId.replace('.json', '')
|
replyPostId = replyPostId.replace('.json', '')
|
||||||
replyPostId = replyPostId.replace('.replies', '')
|
replyPostId = replyPostId.replace('.replies', '')
|
||||||
postFilename = baseDir + '/accounts/' + \
|
postFilename = acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/postcache/' + \
|
'/postcache/' + \
|
||||||
replyPostId.replace('/', '#') + '.html'
|
replyPostId.replace('/', '#') + '.html'
|
||||||
if not os.path.isfile(postFilename):
|
if not os.path.isfile(postFilename):
|
||||||
|
@ -469,8 +468,7 @@ def htmlBlogPage(authorized: bool, session,
|
||||||
blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
|
blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
|
||||||
_htmlBlogRemoveCwButton(blogStr, translate)
|
_htmlBlogRemoveCwButton(blogStr, translate)
|
||||||
|
|
||||||
blogsIndex = baseDir + '/accounts/' + \
|
blogsIndex = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
|
||||||
nickname + '@' + domain + '/tlblogs.index'
|
|
||||||
if not os.path.isfile(blogsIndex):
|
if not os.path.isfile(blogsIndex):
|
||||||
return blogStr + htmlFooter()
|
return blogStr + htmlFooter()
|
||||||
|
|
||||||
|
@ -558,8 +556,7 @@ def htmlBlogPageRSS2(authorized: bool, session,
|
||||||
blogRSS2 = rss2Header(httpPrefix, nickname, domainFull,
|
blogRSS2 = rss2Header(httpPrefix, nickname, domainFull,
|
||||||
'Blog', translate)
|
'Blog', translate)
|
||||||
|
|
||||||
blogsIndex = baseDir + '/accounts/' + \
|
blogsIndex = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
|
||||||
nickname + '@' + domain + '/tlblogs.index'
|
|
||||||
if not os.path.isfile(blogsIndex):
|
if not os.path.isfile(blogsIndex):
|
||||||
if includeHeader:
|
if includeHeader:
|
||||||
return blogRSS2 + rss2Footer()
|
return blogRSS2 + rss2Footer()
|
||||||
|
@ -610,8 +607,7 @@ def htmlBlogPageRSS3(authorized: bool, session,
|
||||||
|
|
||||||
blogRSS3 = ''
|
blogRSS3 = ''
|
||||||
|
|
||||||
blogsIndex = baseDir + '/accounts/' + \
|
blogsIndex = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
|
||||||
nickname + '@' + domain + '/tlblogs.index'
|
|
||||||
if not os.path.isfile(blogsIndex):
|
if not os.path.isfile(blogsIndex):
|
||||||
return blogRSS3
|
return blogRSS3
|
||||||
|
|
||||||
|
@ -876,8 +872,7 @@ def pathContainsBlogLink(baseDir: str,
|
||||||
if not userEnding2[1].isdigit():
|
if not userEnding2[1].isdigit():
|
||||||
return None, None
|
return None, None
|
||||||
# check for blog posts
|
# check for blog posts
|
||||||
blogIndexFilename = baseDir + '/accounts/' + \
|
blogIndexFilename = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
|
||||||
nickname + '@' + domain + '/tlblogs.index'
|
|
||||||
if not os.path.isfile(blogIndexFilename):
|
if not os.path.isfile(blogIndexFilename):
|
||||||
return None, None
|
return None, None
|
||||||
if '#' + userEnding2[1] + '.' not in open(blogIndexFilename).read():
|
if '#' + userEnding2[1] + '.' not in open(blogIndexFilename).read():
|
||||||
|
|
|
@ -24,6 +24,7 @@ from utils import getCachedPostFilename
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from session import postJson
|
from session import postJson
|
||||||
|
|
||||||
|
@ -49,8 +50,8 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
# remove from the index
|
# remove from the index
|
||||||
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
bookmarksIndexFilename = \
|
||||||
nickname + '@' + domain + '/bookmarks.index'
|
acctDir(baseDir, nickname, domain) + '/bookmarks.index'
|
||||||
if not os.path.isfile(bookmarksIndexFilename):
|
if not os.path.isfile(bookmarksIndexFilename):
|
||||||
return
|
return
|
||||||
if '/' in postFilename:
|
if '/' in postFilename:
|
||||||
|
@ -198,8 +199,8 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# prepend to the index
|
# prepend to the index
|
||||||
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
bookmarksIndexFilename = \
|
||||||
nickname + '@' + domain + '/bookmarks.index'
|
acctDir(baseDir, nickname, domain) + '/bookmarks.index'
|
||||||
bookmarkIndex = postFilename.split('/')[-1]
|
bookmarkIndex = postFilename.split('/')[-1]
|
||||||
if os.path.isfile(bookmarksIndexFilename):
|
if os.path.isfile(bookmarksIndexFilename):
|
||||||
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
||||||
|
|
4
city.py
4
city.py
|
@ -12,6 +12,7 @@ import datetime
|
||||||
import random
|
import random
|
||||||
import math
|
import math
|
||||||
from random import randint
|
from random import randint
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
# states which the simulated city dweller can be in
|
# states which the simulated city dweller can be in
|
||||||
PERSON_SLEEP = 0
|
PERSON_SLEEP = 0
|
||||||
|
@ -291,8 +292,7 @@ def getSpoofedCity(city: str, baseDir: str, nickname: str, domain: str) -> str:
|
||||||
"""Returns the name of the city to use as a GPS spoofing location for
|
"""Returns the name of the city to use as a GPS spoofing location for
|
||||||
image metadata
|
image metadata
|
||||||
"""
|
"""
|
||||||
cityFilename = baseDir + '/accounts/' + \
|
cityFilename = acctDir(baseDir, nickname, domain) + '/city.txt'
|
||||||
nickname + '@' + domain + '/city.txt'
|
|
||||||
if os.path.isfile(cityFilename):
|
if os.path.isfile(cityFilename):
|
||||||
with open(cityFilename, 'r') as fp:
|
with open(cityFilename, 'r') as fp:
|
||||||
city = fp.read().replace('\n', '')
|
city = fp.read().replace('\n', '')
|
||||||
|
|
11
content.py
11
content.py
|
@ -20,6 +20,7 @@ from utils import getLinkPrefixes
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
from utils import isPGPEncrypted
|
from utils import isPGPEncrypted
|
||||||
from utils import containsPGPPublicKey
|
from utils import containsPGPPublicKey
|
||||||
|
from utils import acctDir
|
||||||
from petnames import getPetName
|
from petnames import getPetName
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,8 +211,8 @@ def switchWords(baseDir: str, nickname: str, domain: str, content: str,
|
||||||
return content
|
return content
|
||||||
|
|
||||||
if not rules:
|
if not rules:
|
||||||
switchWordsFilename = baseDir + '/accounts/' + \
|
switchWordsFilename = \
|
||||||
nickname + '@' + domain + '/replacewords.txt'
|
acctDir(baseDir, nickname, domain) + '/replacewords.txt'
|
||||||
if not os.path.isfile(switchWordsFilename):
|
if not os.path.isfile(switchWordsFilename):
|
||||||
return content
|
return content
|
||||||
with open(switchWordsFilename, 'r') as fp:
|
with open(switchWordsFilename, 'r') as fp:
|
||||||
|
@ -705,8 +706,7 @@ def _loadAutoTags(baseDir: str, nickname: str, domain: str) -> []:
|
||||||
"""Loads automatic tags file and returns a list containing
|
"""Loads automatic tags file and returns a list containing
|
||||||
the lines of the file
|
the lines of the file
|
||||||
"""
|
"""
|
||||||
filename = baseDir + '/accounts/' + \
|
filename = acctDir(baseDir, nickname, domain) + '/autotags.txt'
|
||||||
nickname + '@' + domain + '/autotags.txt'
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return []
|
return []
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
|
@ -775,8 +775,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
|
||||||
emojiDict = {}
|
emojiDict = {}
|
||||||
originalDomain = domain
|
originalDomain = domain
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
followingFilename = baseDir + '/accounts/' + \
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
nickname + '@' + domain + '/following.txt'
|
|
||||||
|
|
||||||
# read the following list so that we can detect just @nick
|
# read the following list so that we can detect just @nick
|
||||||
# in addition to @nick@domain
|
# in addition to @nick@domain
|
||||||
|
|
129
daemon.py
129
daemon.py
|
@ -208,6 +208,7 @@ from shares import addShare
|
||||||
from shares import removeShare
|
from shares import removeShare
|
||||||
from shares import expireShares
|
from shares import expireShares
|
||||||
from categories import setHashtagCategory
|
from categories import setHashtagCategory
|
||||||
|
from utils import acctDir
|
||||||
from utils import getImageExtensionFromMimeType
|
from utils import getImageExtensionFromMimeType
|
||||||
from utils import getImageMimeType
|
from utils import getImageMimeType
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
@ -378,8 +379,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
answer: str) -> None:
|
answer: str) -> None:
|
||||||
"""Sends a reply to a question
|
"""Sends a reply to a question
|
||||||
"""
|
"""
|
||||||
votesFilename = self.server.baseDir + '/accounts/' + \
|
votesFilename = \
|
||||||
nickname + '@' + self.server.domain + '/questions.txt'
|
acctDir(self.server.baseDir, nickname, self.server.domain) + \
|
||||||
|
'/questions.txt'
|
||||||
|
|
||||||
if os.path.isfile(votesFilename):
|
if os.path.isfile(votesFilename):
|
||||||
# have we already voted on this?
|
# have we already voted on this?
|
||||||
|
@ -1545,8 +1547,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/' + \
|
acctDir(baseDir, loginNickname, domain) + '/.salt'
|
||||||
loginNickname + '@' + domain + '/.salt'
|
|
||||||
salt = createPassword(32)
|
salt = createPassword(32)
|
||||||
if os.path.isfile(saltFilename):
|
if os.path.isfile(saltFilename):
|
||||||
try:
|
try:
|
||||||
|
@ -1885,8 +1886,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if saveKeys:
|
if saveKeys:
|
||||||
accessKeysFilename = \
|
accessKeysFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + '/accessKeys.json'
|
||||||
'/accessKeys.json'
|
|
||||||
saveJson(accessKeys, accessKeysFilename)
|
saveJson(accessKeys, accessKeysFilename)
|
||||||
if not self.server.keyShortcuts.get(nickname):
|
if not self.server.keyShortcuts.get(nickname):
|
||||||
self.server.keyShortcuts[nickname] = accessKeys.copy()
|
self.server.keyShortcuts[nickname] = accessKeys.copy()
|
||||||
|
@ -2134,8 +2134,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
postsToNews = optionsConfirmParams.split('postsToNews=')[1]
|
postsToNews = optionsConfirmParams.split('postsToNews=')[1]
|
||||||
if '&' in postsToNews:
|
if '&' in postsToNews:
|
||||||
postsToNews = postsToNews.split('&')[0]
|
postsToNews = postsToNews.split('&')[0]
|
||||||
accountDir = self.server.baseDir + '/accounts/' + \
|
accountDir = acctDir(self.server.baseDir,
|
||||||
optionsNickname + '@' + optionsDomain
|
optionsNickname, optionsDomain)
|
||||||
newswireBlockedFilename = accountDir + '/.nonewswire'
|
newswireBlockedFilename = accountDir + '/.nonewswire'
|
||||||
if postsToNews == 'on':
|
if postsToNews == 'on':
|
||||||
if os.path.isfile(newswireBlockedFilename):
|
if os.path.isfile(newswireBlockedFilename):
|
||||||
|
@ -2169,8 +2169,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
optionsConfirmParams.split('postsToFeatures=')[1]
|
optionsConfirmParams.split('postsToFeatures=')[1]
|
||||||
if '&' in postsToFeatures:
|
if '&' in postsToFeatures:
|
||||||
postsToFeatures = postsToFeatures.split('&')[0]
|
postsToFeatures = postsToFeatures.split('&')[0]
|
||||||
accountDir = self.server.baseDir + '/accounts/' + \
|
accountDir = acctDir(self.server.baseDir,
|
||||||
optionsNickname + '@' + optionsDomain
|
optionsNickname, optionsDomain)
|
||||||
featuresBlockedFilename = accountDir + '/.nofeatures'
|
featuresBlockedFilename = accountDir + '/.nofeatures'
|
||||||
if postsToFeatures == 'on':
|
if postsToFeatures == 'on':
|
||||||
if os.path.isfile(featuresBlockedFilename):
|
if os.path.isfile(featuresBlockedFilename):
|
||||||
|
@ -2204,8 +2204,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
optionsConfirmParams.split('modNewsPosts=')[1]
|
optionsConfirmParams.split('modNewsPosts=')[1]
|
||||||
if '&' in modPostsToNews:
|
if '&' in modPostsToNews:
|
||||||
modPostsToNews = modPostsToNews.split('&')[0]
|
modPostsToNews = modPostsToNews.split('&')[0]
|
||||||
accountDir = self.server.baseDir + '/accounts/' + \
|
accountDir = acctDir(self.server.baseDir,
|
||||||
optionsNickname + '@' + optionsDomain
|
optionsNickname, optionsDomain)
|
||||||
newswireModFilename = accountDir + '/.newswiremoderated'
|
newswireModFilename = accountDir + '/.newswiremoderated'
|
||||||
if modPostsToNews != 'on':
|
if modPostsToNews != 'on':
|
||||||
if os.path.isfile(newswireModFilename):
|
if os.path.isfile(newswireModFilename):
|
||||||
|
@ -3218,9 +3218,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
self.postFromNickname = pathUsersSection.split('/')[0]
|
self.postFromNickname = pathUsersSection.split('/')[0]
|
||||||
accountsDir = \
|
accountsDir = acctDir(baseDir, self.postFromNickname, domain)
|
||||||
baseDir + '/accounts/' + \
|
|
||||||
self.postFromNickname + '@' + domain
|
|
||||||
if not os.path.isdir(accountsDir):
|
if not os.path.isdir(accountsDir):
|
||||||
self._404()
|
self._404()
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
|
@ -3744,8 +3742,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = getNicknameFromActor(actorStr)
|
nickname = getNicknameFromActor(actorStr)
|
||||||
|
|
||||||
citationsFilename = \
|
citationsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
||||||
nickname + '@' + domain + '/.citations.txt'
|
|
||||||
# remove any existing citations file
|
# remove any existing citations file
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
|
@ -4051,8 +4048,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
else:
|
else:
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/' + mType + '.temp'
|
'/' + mType + '.temp'
|
||||||
|
|
||||||
filename, attachmentMediaType = \
|
filename, attachmentMediaType = \
|
||||||
|
@ -4148,8 +4144,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# load the json for the actor for this user
|
# load the json for the actor for this user
|
||||||
actorFilename = \
|
actorFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '.json'
|
||||||
nickname + '@' + domain + '.json'
|
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actorJson:
|
||||||
|
@ -4240,8 +4235,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# change city
|
# change city
|
||||||
if fields.get('cityDropdown'):
|
if fields.get('cityDropdown'):
|
||||||
cityFilename = baseDir + '/accounts/' + \
|
cityFilename = \
|
||||||
nickname + '@' + domain + '/city.txt'
|
acctDir(baseDir, nickname, domain) + '/city.txt'
|
||||||
with open(cityFilename, 'w+') as fp:
|
with open(cityFilename, 'w+') as fp:
|
||||||
fp.write(fields['cityDropdown'])
|
fp.write(fields['cityDropdown'])
|
||||||
|
|
||||||
|
@ -5015,8 +5010,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# only receive DMs from accounts you follow
|
# only receive DMs from accounts you follow
|
||||||
followDMsFilename = \
|
followDMsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.followDMs'
|
||||||
nickname + '@' + domain + '/.followDMs'
|
|
||||||
if onFinalWelcomeScreen:
|
if onFinalWelcomeScreen:
|
||||||
# initial default setting created via
|
# initial default setting created via
|
||||||
# the welcome screen
|
# the welcome screen
|
||||||
|
@ -5036,8 +5030,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# remove Twitter retweets
|
# remove Twitter retweets
|
||||||
removeTwitterFilename = \
|
removeTwitterFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/.removeTwitter'
|
'/.removeTwitter'
|
||||||
removeTwitterActive = False
|
removeTwitterActive = False
|
||||||
if fields.get('removeTwitter'):
|
if fields.get('removeTwitter'):
|
||||||
|
@ -5052,12 +5045,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# hide Like button
|
# hide Like button
|
||||||
hideLikeButtonFile = \
|
hideLikeButtonFile = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/.hideLikeButton'
|
'/.hideLikeButton'
|
||||||
notifyLikesFilename = \
|
notifyLikesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/.notifyLikes'
|
'/.notifyLikes'
|
||||||
hideLikeButtonActive = False
|
hideLikeButtonActive = False
|
||||||
if fields.get('hideLikeButton'):
|
if fields.get('hideLikeButton'):
|
||||||
|
@ -5123,8 +5114,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# save filtered words list
|
# save filtered words list
|
||||||
filterFilename = \
|
filterFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/filters.txt'
|
'/filters.txt'
|
||||||
if fields.get('filteredWords'):
|
if fields.get('filteredWords'):
|
||||||
with open(filterFilename, 'w+') as filterfile:
|
with open(filterFilename, 'w+') as filterfile:
|
||||||
|
@ -5135,8 +5125,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# word replacements
|
# word replacements
|
||||||
switchFilename = \
|
switchFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/replacewords.txt'
|
'/replacewords.txt'
|
||||||
if fields.get('switchWords'):
|
if fields.get('switchWords'):
|
||||||
with open(switchFilename, 'w+') as switchfile:
|
with open(switchFilename, 'w+') as switchfile:
|
||||||
|
@ -5147,8 +5136,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# autogenerated tags
|
# autogenerated tags
|
||||||
autoTagsFilename = \
|
autoTagsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/autotags.txt'
|
'/autotags.txt'
|
||||||
if fields.get('autoTags'):
|
if fields.get('autoTags'):
|
||||||
with open(autoTagsFilename, 'w+') as autoTagsFile:
|
with open(autoTagsFilename, 'w+') as autoTagsFile:
|
||||||
|
@ -5159,8 +5147,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# autogenerated content warnings
|
# autogenerated content warnings
|
||||||
autoCWFilename = \
|
autoCWFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/autocw.txt'
|
'/autocw.txt'
|
||||||
if fields.get('autoCW'):
|
if fields.get('autoCW'):
|
||||||
with open(autoCWFilename, 'w+') as autoCWFile:
|
with open(autoCWFilename, 'w+') as autoCWFile:
|
||||||
|
@ -5171,8 +5158,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# save blocked accounts list
|
# save blocked accounts list
|
||||||
blockedFilename = \
|
blockedFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/blocking.txt'
|
'/blocking.txt'
|
||||||
if fields.get('blocked'):
|
if fields.get('blocked'):
|
||||||
with open(blockedFilename, 'w+') as blockedfile:
|
with open(blockedFilename, 'w+') as blockedfile:
|
||||||
|
@ -5185,8 +5171,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# The allow list for incoming DMs,
|
# The allow list for incoming DMs,
|
||||||
# if the .followDMs flag file exists
|
# if the .followDMs flag file exists
|
||||||
dmAllowedInstancesFilename = \
|
dmAllowedInstancesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + '/dmAllowedinstances.txt'
|
'/dmAllowedinstances.txt'
|
||||||
if fields.get('dmAllowedInstances'):
|
if fields.get('dmAllowedInstances'):
|
||||||
with open(dmAllowedInstancesFilename, 'w+') as aFile:
|
with open(dmAllowedInstancesFilename, 'w+') as aFile:
|
||||||
aFile.write(fields['dmAllowedInstances'])
|
aFile.write(fields['dmAllowedInstances'])
|
||||||
|
@ -5197,8 +5183,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# save allowed instances list
|
# save allowed instances list
|
||||||
# This is the account level allow list
|
# This is the account level allow list
|
||||||
allowedInstancesFilename = \
|
allowedInstancesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + '/allowedinstances.txt'
|
'/allowedinstances.txt'
|
||||||
if fields.get('allowedInstances'):
|
if fields.get('allowedInstances'):
|
||||||
with open(allowedInstancesFilename, 'w+') as aFile:
|
with open(allowedInstancesFilename, 'w+') as aFile:
|
||||||
aFile.write(fields['allowedInstances'])
|
aFile.write(fields['allowedInstances'])
|
||||||
|
@ -5254,8 +5240,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# save git project names list
|
# save git project names list
|
||||||
gitProjectsFilename = \
|
gitProjectsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
nickname + '@' + domain + \
|
|
||||||
'/gitprojects.txt'
|
'/gitprojects.txt'
|
||||||
if fields.get('gitProjects'):
|
if fields.get('gitProjects'):
|
||||||
with open(gitProjectsFilename, 'w+') as aFile:
|
with open(gitProjectsFilename, 'w+') as aFile:
|
||||||
|
@ -5506,7 +5491,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
speakerFilename = \
|
speakerFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
acctDir(baseDir, nickname, domain) + '/speaker.json'
|
||||||
if not os.path.isfile(speakerFilename):
|
if not os.path.isfile(speakerFilename):
|
||||||
self._404()
|
self._404()
|
||||||
return
|
return
|
||||||
|
@ -5607,8 +5592,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
if not nickname.startswith('rss.'):
|
if not nickname.startswith('rss.'):
|
||||||
if os.path.isdir(self.server.baseDir +
|
accountDir = acctDir(self.server.baseDir, nickname, domain)
|
||||||
'/accounts/' + nickname + '@' + domain):
|
if os.path.isdir(accountDir):
|
||||||
if not self.server.session:
|
if not self.server.session:
|
||||||
print('Starting new session during RSS request')
|
print('Starting new session during RSS request')
|
||||||
self.server.session = \
|
self.server.session = \
|
||||||
|
@ -5793,8 +5778,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
if not nickname.startswith('rss.'):
|
if not nickname.startswith('rss.'):
|
||||||
if os.path.isdir(baseDir +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
'/accounts/' + nickname + '@' + domain):
|
if os.path.isdir(accountDir):
|
||||||
if not self.server.session:
|
if not self.server.session:
|
||||||
print('Starting new session during RSS3 request')
|
print('Starting new session during RSS3 request')
|
||||||
self.server.session = \
|
self.server.session = \
|
||||||
|
@ -7265,7 +7250,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
boxname = 'outbox'
|
boxname = 'outbox'
|
||||||
# get the replies file
|
# get the replies file
|
||||||
postDir = \
|
postDir = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxname
|
acctDir(baseDir, nickname, domain) + '/' + boxname
|
||||||
postRepliesFilename = \
|
postRepliesFilename = \
|
||||||
postDir + '/' + \
|
postDir + '/' + \
|
||||||
httpPrefix + ':##' + domainFull + '#users#' + \
|
httpPrefix + ':##' + domainFull + '#users#' + \
|
||||||
|
@ -7465,8 +7450,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
postSections = namedStatus.split('/')
|
postSections = namedStatus.split('/')
|
||||||
nickname = postSections[0]
|
nickname = postSections[0]
|
||||||
actorFilename = \
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -7562,9 +7546,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in namedStatus:
|
if '/' in namedStatus:
|
||||||
postSections = namedStatus.split('/')
|
postSections = namedStatus.split('/')
|
||||||
nickname = postSections[0]
|
nickname = postSections[0]
|
||||||
actorFilename = \
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
baseDir + '/accounts/' + \
|
|
||||||
nickname + '@' + domain + '.json'
|
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actorJson:
|
||||||
|
@ -7691,7 +7673,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
postFilename = \
|
postFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/outbox/' + \
|
acctDir(baseDir, nickname, domain) + '/outbox/' + \
|
||||||
httpPrefix + ':##' + domainFull + '#users#' + nickname + \
|
httpPrefix + ':##' + domainFull + '#users#' + nickname + \
|
||||||
'#statuses#' + statusNumber + '.json'
|
'#statuses#' + statusNumber + '.json'
|
||||||
|
|
||||||
|
@ -7809,7 +7791,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
postFilename = \
|
postFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/outbox/' + \
|
acctDir(baseDir, nickname, domain) + '/outbox/' + \
|
||||||
httpPrefix + ':##' + domainFull + '#users#' + nickname + \
|
httpPrefix + ':##' + domainFull + '#users#' + nickname + \
|
||||||
'#statuses#' + statusNumber + '.json'
|
'#statuses#' + statusNumber + '.json'
|
||||||
|
|
||||||
|
@ -9868,7 +9850,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
savePersonQrcode(baseDir, nickname, domain, port)
|
savePersonQrcode(baseDir, nickname, domain, port)
|
||||||
qrFilename = \
|
qrFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/qrcode.png'
|
acctDir(baseDir, nickname, domain) + '/qrcode.png'
|
||||||
if os.path.isfile(qrFilename):
|
if os.path.isfile(qrFilename):
|
||||||
if self._etag_exists(qrFilename):
|
if self._etag_exists(qrFilename):
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
|
@ -9906,8 +9888,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"""
|
"""
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
bannerFilename = \
|
bannerFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/search_banner.png'
|
||||||
nickname + '@' + domain + '/search_banner.png'
|
|
||||||
if os.path.isfile(bannerFilename):
|
if os.path.isfile(bannerFilename):
|
||||||
if self._etag_exists(bannerFilename):
|
if self._etag_exists(bannerFilename):
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
|
@ -9949,8 +9930,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._404()
|
self._404()
|
||||||
return True
|
return True
|
||||||
bannerFilename = \
|
bannerFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/' + side + '_col_image.png'
|
||||||
nickname + '@' + domain + '/' + side + '_col_image.png'
|
|
||||||
if os.path.isfile(bannerFilename):
|
if os.path.isfile(bannerFilename):
|
||||||
if self._etag_exists(bannerFilename):
|
if self._etag_exists(bannerFilename):
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
|
@ -10099,8 +10079,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
elif avatarFile.startswith('right_col_image'):
|
elif avatarFile.startswith('right_col_image'):
|
||||||
avatarFile = 'right_col_image.' + avatarFileExt
|
avatarFile = 'right_col_image.' + avatarFileExt
|
||||||
avatarFilename = \
|
avatarFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, avatarNickname, domain) + '/' + avatarFile
|
||||||
avatarNickname + '@' + domain + '/' + avatarFile
|
|
||||||
if not os.path.isfile(avatarFilename):
|
if not os.path.isfile(avatarFilename):
|
||||||
return False
|
return False
|
||||||
if self._etag_exists(avatarFilename):
|
if self._etag_exists(avatarFilename):
|
||||||
|
@ -11071,8 +11050,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.path.endswith('/followingaccounts'):
|
self.path.endswith('/followingaccounts'):
|
||||||
nickname = getNicknameFromActor(self.path)
|
nickname = getNicknameFromActor(self.path)
|
||||||
followingFilename = \
|
followingFilename = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
acctDir(self.server.baseDir,
|
||||||
nickname + '@' + self.server.domain + '/following.txt'
|
nickname, self.server.domain) + '/following.txt'
|
||||||
if not os.path.isfile(followingFilename):
|
if not os.path.isfile(followingFilename):
|
||||||
self._404()
|
self._404()
|
||||||
return
|
return
|
||||||
|
@ -12966,8 +12945,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# Note: a .temp extension is used here so that at no time is
|
# Note: a .temp extension is used here so that at no time is
|
||||||
# an image with metadata publicly exposed, even for a few mS
|
# an image with metadata publicly exposed, even for a few mS
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
acctDir(self.server.baseDir,
|
||||||
nickname + '@' + self.server.domain + '/upload.temp'
|
nickname, self.server.domain) + '/upload.temp'
|
||||||
|
|
||||||
filename, attachmentMediaType = \
|
filename, attachmentMediaType = \
|
||||||
saveMediaInFormPOST(mediaBytes, self.server.debug,
|
saveMediaInFormPOST(mediaBytes, self.server.debug,
|
||||||
|
@ -13061,8 +13040,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# since epoch when an attempt to post something was made.
|
# since epoch when an attempt to post something was made.
|
||||||
# This is then used for active monthly users counts
|
# This is then used for active monthly users counts
|
||||||
lastUsedFilename = \
|
lastUsedFilename = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
acctDir(self.server.baseDir,
|
||||||
nickname + '@' + self.server.domain + '/.lastUsed'
|
nickname, self.server.domain) + '/.lastUsed'
|
||||||
try:
|
try:
|
||||||
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
||||||
lastUsedFile.write(str(int(time.time())))
|
lastUsedFile.write(str(int(time.time())))
|
||||||
|
@ -13203,8 +13182,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
postJsonObject = loadJson(postFilename)
|
postJsonObject = loadJson(postFilename)
|
||||||
if postJsonObject:
|
if postJsonObject:
|
||||||
cachedFilename = \
|
cachedFilename = \
|
||||||
self.server.baseDir + '/accounts/' + \
|
acctDir(self.server.baseDir,
|
||||||
nickname + '@' + self.server.domain + \
|
nickname, self.server.domain) + \
|
||||||
'/postcache/' + \
|
'/postcache/' + \
|
||||||
fields['postUrl'].replace('/', '#') + '.html'
|
fields['postUrl'].replace('/', '#') + '.html'
|
||||||
if os.path.isfile(cachedFilename):
|
if os.path.isfile(cachedFilename):
|
||||||
|
|
|
@ -33,13 +33,14 @@ __module_group__ = "Security"
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
||||||
deviceId: str) -> bool:
|
deviceId: str) -> bool:
|
||||||
"""Unregisters a device for e2ee
|
"""Unregisters a device for e2ee
|
||||||
"""
|
"""
|
||||||
personDir = baseDir + '/accounts/' + nickname + '@' + domain
|
personDir = acctDir(baseDir, nickname, domain)
|
||||||
deviceFilename = personDir + '/devices/' + deviceId + '.json'
|
deviceFilename = personDir + '/devices/' + deviceId + '.json'
|
||||||
if os.path.isfile(deviceFilename):
|
if os.path.isfile(deviceFilename):
|
||||||
os.remove(deviceFilename)
|
os.remove(deviceFilename)
|
||||||
|
@ -111,7 +112,7 @@ def E2EEaddDevice(baseDir: str, nickname: str, domain: str,
|
||||||
'?' in deviceId or '#' in deviceId or \
|
'?' in deviceId or '#' in deviceId or \
|
||||||
'.' in deviceId:
|
'.' in deviceId:
|
||||||
return False
|
return False
|
||||||
personDir = baseDir + '/accounts/' + nickname + '@' + domain
|
personDir = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(personDir):
|
if not os.path.isdir(personDir):
|
||||||
return False
|
return False
|
||||||
if not os.path.isdir(personDir + '/devices'):
|
if not os.path.isdir(personDir + '/devices'):
|
||||||
|
@ -138,7 +139,7 @@ def E2EEdevicesCollection(baseDir: str, nickname: str, domain: str,
|
||||||
domainFull: str, httpPrefix: str) -> {}:
|
domainFull: str, httpPrefix: str) -> {}:
|
||||||
"""Returns a list of registered devices
|
"""Returns a list of registered devices
|
||||||
"""
|
"""
|
||||||
personDir = baseDir + '/accounts/' + nickname + '@' + domain
|
personDir = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(personDir):
|
if not os.path.isdir(personDir):
|
||||||
return {}
|
return {}
|
||||||
personId = httpPrefix + '://' + domainFull + '/users/' + nickname
|
personId = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
|
|
16
epicyon.py
16
epicyon.py
|
@ -72,6 +72,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import followPerson
|
from utils import followPerson
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
|
from utils import acctDir
|
||||||
from media import archiveMedia
|
from media import archiveMedia
|
||||||
from media import getAttachmentMediaType
|
from media import getAttachmentMediaType
|
||||||
from delete import sendDeleteViaServer
|
from delete import sendDeleteViaServer
|
||||||
|
@ -1040,7 +1041,7 @@ if args.followerspending:
|
||||||
print('Specify a nickname with the --nickname option')
|
print('Specify a nickname with the --nickname option')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
accountsDir = baseDir + '/accounts/' + args.nickname + '@' + domain
|
accountsDir = acctDir(baseDir, args.nickname, domain)
|
||||||
approveFollowsFilename = accountsDir + '/followrequests.txt'
|
approveFollowsFilename = accountsDir + '/followrequests.txt'
|
||||||
approveCtr = 0
|
approveCtr = 0
|
||||||
if os.path.isfile(approveFollowsFilename):
|
if os.path.isfile(approveFollowsFilename):
|
||||||
|
@ -1788,7 +1789,8 @@ if args.addaccount:
|
||||||
if len(args.password.strip()) < 8:
|
if len(args.password.strip()) < 8:
|
||||||
print('Password should be at least 8 characters')
|
print('Password should be at least 8 characters')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
if os.path.isdir(accountDir):
|
||||||
print('Account already exists')
|
print('Account already exists')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if os.path.isdir(baseDir + '/deactivated/' + nickname + '@' + domain):
|
if os.path.isdir(baseDir + '/deactivated/' + nickname + '@' + domain):
|
||||||
|
@ -1800,7 +1802,7 @@ if args.addaccount:
|
||||||
httpPrefix = 'http'
|
httpPrefix = 'http'
|
||||||
createPerson(baseDir, nickname, domain, port, httpPrefix,
|
createPerson(baseDir, nickname, domain, port, httpPrefix,
|
||||||
True, not args.noapproval, args.password.strip())
|
True, not args.noapproval, args.password.strip())
|
||||||
if os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
if os.path.isdir(accountDir):
|
||||||
print('Account created for ' + nickname + '@' + domain)
|
print('Account created for ' + nickname + '@' + domain)
|
||||||
else:
|
else:
|
||||||
print('Account creation failed')
|
print('Account creation failed')
|
||||||
|
@ -1827,12 +1829,13 @@ if args.addgroup:
|
||||||
if len(args.password.strip()) < 8:
|
if len(args.password.strip()) < 8:
|
||||||
print('Password should be at least 8 characters')
|
print('Password should be at least 8 characters')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
if os.path.isdir(accountDir):
|
||||||
print('Group already exists')
|
print('Group already exists')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
createGroup(baseDir, nickname, domain, port, httpPrefix,
|
createGroup(baseDir, nickname, domain, port, httpPrefix,
|
||||||
True, args.password.strip())
|
True, args.password.strip())
|
||||||
if os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
if os.path.isdir(accountDir):
|
||||||
print('Group created for ' + nickname + '@' + domain)
|
print('Group created for ' + nickname + '@' + domain)
|
||||||
else:
|
else:
|
||||||
print('Group creation failed')
|
print('Group creation failed')
|
||||||
|
@ -1910,7 +1913,8 @@ if args.changepassword:
|
||||||
if len(newPassword) < 8:
|
if len(newPassword) < 8:
|
||||||
print('Password should be at least 8 characters')
|
print('Password should be at least 8 characters')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
if not os.path.isdir(accountDir):
|
||||||
print('Account ' + nickname + '@' + domain + ' not found')
|
print('Account ' + nickname + '@' + domain + ' not found')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
passwordFile = baseDir + '/accounts/passwords'
|
passwordFile = baseDir + '/accounts/passwords'
|
||||||
|
|
14
filters.py
14
filters.py
|
@ -8,13 +8,13 @@ __status__ = "Production"
|
||||||
__module_group__ = "Moderation"
|
__module_group__ = "Moderation"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
||||||
"""Adds a filter for particular words within the content of a incoming posts
|
"""Adds a filter for particular words within the content of a incoming posts
|
||||||
"""
|
"""
|
||||||
filtersFilename = baseDir + '/accounts/' + \
|
filtersFilename = acctDir(baseDir, nickname, domain) + '/filters.txt'
|
||||||
nickname + '@' + domain + '/filters.txt'
|
|
||||||
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
|
||||||
|
@ -44,8 +44,7 @@ def removeFilter(baseDir: str, nickname: str, domain: str,
|
||||||
words: str) -> bool:
|
words: str) -> bool:
|
||||||
"""Removes a word filter
|
"""Removes a word filter
|
||||||
"""
|
"""
|
||||||
filtersFilename = baseDir + '/accounts/' + \
|
filtersFilename = acctDir(baseDir, nickname, domain) + '/filters.txt'
|
||||||
nickname + '@' + domain + '/filters.txt'
|
|
||||||
if not os.path.isfile(filtersFilename):
|
if not os.path.isfile(filtersFilename):
|
||||||
return False
|
return False
|
||||||
if words not in open(filtersFilename).read():
|
if words not in open(filtersFilename).read():
|
||||||
|
@ -134,12 +133,11 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# optionally remove retweets
|
# optionally remove retweets
|
||||||
removeTwitter = baseDir + '/accounts/' + \
|
removeTwitter = acctDir(baseDir, nickname, domain) + '/.removeTwitter'
|
||||||
nickname + '@' + domain + '/.removeTwitter'
|
|
||||||
if os.path.isfile(removeTwitter):
|
if os.path.isfile(removeTwitter):
|
||||||
if _isTwitterPost(content):
|
if _isTwitterPost(content):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
accountFiltersFilename = baseDir + '/accounts/' + \
|
accountFiltersFilename = \
|
||||||
nickname + '@' + domain + '/filters.txt'
|
acctDir(baseDir, nickname, domain) + '/filters.txt'
|
||||||
return _isFilteredBase(accountFiltersFilename, content)
|
return _isFilteredBase(accountFiltersFilename, content)
|
||||||
|
|
13
follow.py
13
follow.py
|
@ -27,6 +27,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
|
from utils import acctDir
|
||||||
from acceptreject import createAccept
|
from acceptreject import createAccept
|
||||||
from acceptreject import createReject
|
from acceptreject import createReject
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -207,8 +208,7 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
"""is the given nickname a follower of followerNickname?
|
"""is the given nickname a follower of followerNickname?
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
followersFile = baseDir + '/accounts/' + \
|
followersFile = acctDir(baseDir, nickname, domain) + '/followers.txt'
|
||||||
nickname + '@' + domain + '/followers.txt'
|
|
||||||
if not os.path.isfile(followersFile):
|
if not os.path.isfile(followersFile):
|
||||||
return False
|
return False
|
||||||
handle = followerNickname + '@' + followerDomain
|
handle = followerNickname + '@' + followerDomain
|
||||||
|
@ -806,8 +806,8 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
||||||
if removeFollowActivity:
|
if removeFollowActivity:
|
||||||
# remove the follow request json
|
# remove the follow request json
|
||||||
followActivityfilename = \
|
followActivityfilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nicknameToFollow, domainToFollow) + \
|
||||||
nicknameToFollow + '@' + domainToFollow + '/requests/' + \
|
'/requests/' + \
|
||||||
nickname + '@' + domain + '.follow'
|
nickname + '@' + domain + '.follow'
|
||||||
if os.path.isfile(followActivityfilename):
|
if os.path.isfile(followActivityfilename):
|
||||||
try:
|
try:
|
||||||
|
@ -844,8 +844,7 @@ def followedAccountRejects(session, baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
# get the json for the original follow request
|
# get the json for the original follow request
|
||||||
followActivityfilename = \
|
followActivityfilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nicknameToFollow, domainToFollow) + '/requests/' + \
|
||||||
nicknameToFollow + '@' + domainToFollow + '/requests/' + \
|
|
||||||
nickname + '@' + domain + '.follow'
|
nickname + '@' + domain + '.follow'
|
||||||
followJson = loadJson(followActivityfilename)
|
followJson = loadJson(followActivityfilename)
|
||||||
if not followJson:
|
if not followJson:
|
||||||
|
@ -1433,7 +1432,7 @@ def followerApprovalActive(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Returns true if the given account requires follower approval
|
"""Returns true if the given account requires follower approval
|
||||||
"""
|
"""
|
||||||
manuallyApprovesFollowers = False
|
manuallyApprovesFollowers = False
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actorJson:
|
||||||
|
|
|
@ -10,6 +10,9 @@ __module_group__ = "Calendar"
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def _dirAcct(baseDir: str, nickname: str, domain: str) -> str:
|
||||||
|
return baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
|
||||||
def _portDomainRemove(domain: str) -> str:
|
def _portDomainRemove(domain: str) -> str:
|
||||||
"""If the domain has a port appended then remove it
|
"""If the domain has a port appended then remove it
|
||||||
eg. mydomain.com:80 becomes mydomain.com
|
eg. mydomain.com:80 becomes mydomain.com
|
||||||
|
@ -31,12 +34,12 @@ def receivingCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
if followingNickname == nickname and followingDomain == domain:
|
if followingNickname == nickname and followingDomain == domain:
|
||||||
# reminder post
|
# reminder post
|
||||||
return True
|
return True
|
||||||
calendarFilename = baseDir + '/accounts/' + \
|
calendarFilename = \
|
||||||
nickname + '@' + domain + '/followingCalendar.txt'
|
_dirAcct(baseDir, nickname, domain) + '/followingCalendar.txt'
|
||||||
handle = followingNickname + '@' + followingDomain
|
handle = followingNickname + '@' + followingDomain
|
||||||
if not os.path.isfile(calendarFilename):
|
if not os.path.isfile(calendarFilename):
|
||||||
followingFilename = baseDir + '/accounts/' + \
|
followingFilename = \
|
||||||
nickname + '@' + domain + '/following.txt'
|
_dirAcct(baseDir, nickname, domain) + '/following.txt'
|
||||||
if not os.path.isfile(followingFilename):
|
if not os.path.isfile(followingFilename):
|
||||||
return False
|
return False
|
||||||
# create a new calendar file from the following file
|
# create a new calendar file from the following file
|
||||||
|
@ -56,8 +59,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
# check that a following file exists
|
# check that a following file exists
|
||||||
domain = _portDomainRemove(domain)
|
domain = _portDomainRemove(domain)
|
||||||
followingFilename = baseDir + '/accounts/' + \
|
followingFilename = _dirAcct(baseDir, nickname, domain) + '/following.txt'
|
||||||
nickname + '@' + domain + '/following.txt'
|
|
||||||
if not os.path.isfile(followingFilename):
|
if not os.path.isfile(followingFilename):
|
||||||
print("WARN: following.txt doesn't exist for " +
|
print("WARN: following.txt doesn't exist for " +
|
||||||
nickname + '@' + domain)
|
nickname + '@' + domain)
|
||||||
|
@ -69,8 +71,8 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
print('WARN: ' + handle + ' is not in ' + followingFilename)
|
print('WARN: ' + handle + ' is not in ' + followingFilename)
|
||||||
return
|
return
|
||||||
|
|
||||||
calendarFilename = baseDir + '/accounts/' + \
|
calendarFilename = \
|
||||||
nickname + '@' + domain + '/followingCalendar.txt'
|
_dirAcct(baseDir, nickname, domain) + '/followingCalendar.txt'
|
||||||
|
|
||||||
# get the contents of the calendar file, which is
|
# get the contents of the calendar file, which is
|
||||||
# a set of handles
|
# a set of handles
|
||||||
|
|
10
git.py
10
git.py
|
@ -10,6 +10,7 @@ __module_group__ = "Profile Metadata"
|
||||||
import os
|
import os
|
||||||
import html
|
import html
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _gitFormatContent(content: str) -> str:
|
def _gitFormatContent(content: str) -> str:
|
||||||
|
@ -32,7 +33,7 @@ def _getGitProjectName(baseDir: str, nickname: str, domain: str,
|
||||||
holder wants to receive
|
holder wants to receive
|
||||||
"""
|
"""
|
||||||
gitProjectsFilename = \
|
gitProjectsFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/gitprojects.txt'
|
acctDir(baseDir, nickname, domain) + '/gitprojects.txt'
|
||||||
if not os.path.isfile(gitProjectsFilename):
|
if not os.path.isfile(gitProjectsFilename):
|
||||||
return None
|
return None
|
||||||
subjectLineWords = subject.lower().split(' ')
|
subjectLineWords = subject.lower().split(' ')
|
||||||
|
@ -186,9 +187,7 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
|
||||||
patchLines = patchStr.split('\n')
|
patchLines = patchStr.split('\n')
|
||||||
patchFilename = None
|
patchFilename = None
|
||||||
projectDir = None
|
projectDir = None
|
||||||
patchesDir = \
|
patchesDir = acctDir(baseDir, nickname, domain) + '/patches'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
|
||||||
'/patches'
|
|
||||||
# get the subject line and turn it into a filename
|
# get the subject line and turn it into a filename
|
||||||
for line in patchLines:
|
for line in patchLines:
|
||||||
if line.startswith('Subject:'):
|
if line.startswith('Subject:'):
|
||||||
|
@ -213,8 +212,7 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
|
||||||
with open(patchFilename, 'w+') as patchFile:
|
with open(patchFilename, 'w+') as patchFile:
|
||||||
patchFile.write(patchStr)
|
patchFile.write(patchStr)
|
||||||
patchNotifyFilename = \
|
patchNotifyFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.newPatchContent'
|
||||||
nickname + '@' + domain + '/.newPatchContent'
|
|
||||||
with open(patchNotifyFilename, 'w+') as patchFile:
|
with open(patchNotifyFilename, 'w+') as patchFile:
|
||||||
patchFile.write(patchStr)
|
patchFile.write(patchStr)
|
||||||
return True
|
return True
|
||||||
|
|
11
happening.py
11
happening.py
|
@ -17,6 +17,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _validUuid(testUuid: str, version: int = 4):
|
def _validUuid(testUuid: str, version: int = 4):
|
||||||
|
@ -182,7 +183,7 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
dayNumber = currDayOfMonth
|
dayNumber = currDayOfMonth
|
||||||
|
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
||||||
events = {}
|
events = {}
|
||||||
if not os.path.isfile(calendarFilename):
|
if not os.path.isfile(calendarFilename):
|
||||||
|
@ -255,7 +256,7 @@ def dayEventsCheck(baseDir: str, nickname: str, domain: str, currDate) -> bool:
|
||||||
dayNumber = currDate.day
|
dayNumber = currDate.day
|
||||||
|
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
||||||
if not os.path.isfile(calendarFilename):
|
if not os.path.isfile(calendarFilename):
|
||||||
return False
|
return False
|
||||||
|
@ -308,7 +309,7 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
monthNumber = now.month
|
monthNumber = now.month
|
||||||
|
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
||||||
|
|
||||||
events = {}
|
events = {}
|
||||||
|
@ -370,7 +371,7 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
Event and Place activities
|
Event and Place activities
|
||||||
"""
|
"""
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
||||||
|
|
||||||
events = {}
|
events = {}
|
||||||
|
@ -432,7 +433,7 @@ def removeCalendarEvent(baseDir: str, nickname: str, domain: str,
|
||||||
"""Removes a calendar event
|
"""Removes a calendar event
|
||||||
"""
|
"""
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
'/calendar/' + str(year) + '/' + str(monthNumber) + '.txt'
|
||||||
if not os.path.isfile(calendarFilename):
|
if not os.path.isfile(calendarFilename):
|
||||||
return
|
return
|
||||||
|
|
14
inbox.py
14
inbox.py
|
@ -13,6 +13,7 @@ import datetime
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
from linked_data_sig import verifyJsonSignature
|
from linked_data_sig import verifyJsonSignature
|
||||||
|
from utils import acctDir
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import getPortFromDomain
|
from utils import getPortFromDomain
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
@ -190,7 +191,7 @@ def validInbox(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Checks whether files were correctly saved to the inbox
|
"""Checks whether files were correctly saved to the inbox
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
inboxDir = baseDir + '/accounts/' + nickname + '@' + domain + '/inbox'
|
inboxDir = acctDir(baseDir, 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):
|
||||||
|
@ -212,7 +213,7 @@ def validInboxFilenames(baseDir: str, nickname: str, domain: str,
|
||||||
domain names within saved post filenames
|
domain names within saved post filenames
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
inboxDir = baseDir + '/accounts/' + nickname + '@' + domain + '/inbox'
|
inboxDir = acctDir(baseDir, nickname, domain) + '/inbox'
|
||||||
if not os.path.isdir(inboxDir):
|
if not os.path.isdir(inboxDir):
|
||||||
return True
|
return True
|
||||||
expectedStr = expectedDomain + ':' + str(expectedPort)
|
expectedStr = expectedDomain + ':' + str(expectedPort)
|
||||||
|
@ -2078,7 +2079,7 @@ def _updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
||||||
nickname = handle.split('@')[0]
|
nickname = handle.split('@')[0]
|
||||||
domain = handle.split('@')[1]
|
domain = handle.split('@')[1]
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
accountPath = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
return
|
return
|
||||||
if not isFollowingActor(baseDir, nickname, domain, actor):
|
if not isFollowingActor(baseDir, nickname, domain, actor):
|
||||||
|
@ -2191,8 +2192,7 @@ def _isValidDM(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
# check for the flag file which indicates to
|
# check for the flag file which indicates to
|
||||||
# only receive DMs from people you are following
|
# only receive DMs from people you are following
|
||||||
followDMsFilename = \
|
followDMsFilename = acctDir(baseDir, nickname, domain) + '/.followDMs'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/.followDMs'
|
|
||||||
if not os.path.isfile(followDMsFilename):
|
if not os.path.isfile(followDMsFilename):
|
||||||
# dm index will be updated
|
# dm index will be updated
|
||||||
updateIndexList.append('dm')
|
updateIndexList.append('dm')
|
||||||
|
@ -2201,9 +2201,7 @@ def _isValidDM(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# get the file containing following handles
|
# get the file containing following handles
|
||||||
followingFilename = \
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
baseDir + '/accounts/' + \
|
|
||||||
nickname + '@' + domain + '/following.txt'
|
|
||||||
# who is sending a DM?
|
# who is sending a DM?
|
||||||
if not postJsonObject.get('actor'):
|
if not postJsonObject.get('actor'):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -15,6 +15,7 @@ from utils import loadJson
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import getPortFromDomain
|
from utils import getPortFromDomain
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def manualDenyFollowRequest(session, baseDir: str,
|
def manualDenyFollowRequest(session, baseDir: str,
|
||||||
|
@ -28,8 +29,7 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
projectVersion: str) -> None:
|
projectVersion: str) -> None:
|
||||||
"""Manually deny a follow request
|
"""Manually deny a follow request
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
accountsDir = acctDir(baseDir, nickname, domain)
|
||||||
accountsDir = baseDir + '/accounts/' + handle
|
|
||||||
|
|
||||||
# has this handle already been rejected?
|
# has this handle already been rejected?
|
||||||
rejectedFollowsFilename = accountsDir + '/followrejects.txt'
|
rejectedFollowsFilename = accountsDir + '/followrejects.txt'
|
||||||
|
|
|
@ -10,6 +10,7 @@ __module_group__ = "API"
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
|
from utils import acctDir
|
||||||
from metadata import metaDataInstance
|
from metadata import metaDataInstance
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,8 +55,7 @@ def _getMastoApiV1Account(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
blob/master/Using-the-API/API.md#account
|
blob/master/Using-the-API/API.md#account
|
||||||
Authorization has already been performed
|
Authorization has already been performed
|
||||||
"""
|
"""
|
||||||
accountFilename = \
|
accountFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
|
||||||
if not os.path.isfile(accountFilename):
|
if not os.path.isfile(accountFilename):
|
||||||
return {}
|
return {}
|
||||||
accountJson = loadJson(accountFilename)
|
accountJson = loadJson(accountFilename)
|
||||||
|
|
4
media.py
4
media.py
|
@ -19,6 +19,7 @@ from utils import getVideoExtensions
|
||||||
from utils import getAudioExtensions
|
from utils import getAudioExtensions
|
||||||
from utils import getMediaExtensions
|
from utils import getMediaExtensions
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from shutil import move
|
from shutil import move
|
||||||
|
@ -67,8 +68,7 @@ def _spoofMetaData(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
# get the random seed used to generate a unique pattern for this account
|
# get the random seed used to generate a unique pattern for this account
|
||||||
decoySeedFilename = \
|
decoySeedFilename = acctDir(baseDir, nickname, domain) + '/decoyseed'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/decoyseed'
|
|
||||||
decoySeed = 63725
|
decoySeed = 63725
|
||||||
if os.path.isfile(decoySeedFilename):
|
if os.path.isfile(decoySeedFilename):
|
||||||
with open(decoySeedFilename, 'r') as fp:
|
with open(decoySeedFilename, 'r') as fp:
|
||||||
|
|
12
migrate.py
12
migrate.py
|
@ -11,6 +11,7 @@ import os
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
|
from utils import acctDir
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
from posts import getUserUrl
|
from posts import getUserUrl
|
||||||
|
@ -25,8 +26,7 @@ def _moveFollowingHandlesForAccount(baseDir: str, nickname: str, domain: str,
|
||||||
"""Goes through all follows for an account and updates any that have moved
|
"""Goes through all follows for an account and updates any that have moved
|
||||||
"""
|
"""
|
||||||
ctr = 0
|
ctr = 0
|
||||||
followingFilename = \
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/following.txt'
|
|
||||||
if not os.path.isfile(followingFilename):
|
if not os.path.isfile(followingFilename):
|
||||||
return ctr
|
return ctr
|
||||||
with open(followingFilename, 'r') as f:
|
with open(followingFilename, 'r') as f:
|
||||||
|
@ -111,8 +111,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
'following.txt', debug)
|
'following.txt', debug)
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
followingFilename = \
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/following.txt'
|
|
||||||
if os.path.isfile(followingFilename):
|
if os.path.isfile(followingFilename):
|
||||||
with open(followingFilename, 'r') as f:
|
with open(followingFilename, 'r') as f:
|
||||||
followingHandles = f.readlines()
|
followingHandles = f.readlines()
|
||||||
|
@ -121,8 +120,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
handleLower = handle.lower()
|
handleLower = handle.lower()
|
||||||
|
|
||||||
refollowFilename = \
|
refollowFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/refollow.txt'
|
||||||
nickname + '@' + domain + '/refollow.txt'
|
|
||||||
|
|
||||||
# unfollow the old handle
|
# unfollow the old handle
|
||||||
with open(followingFilename, 'w+') as f:
|
with open(followingFilename, 'w+') as f:
|
||||||
|
@ -150,7 +148,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
f.write(movedToHandle + '\n')
|
f.write(movedToHandle + '\n')
|
||||||
|
|
||||||
followersFilename = \
|
followersFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/followers.txt'
|
acctDir(baseDir, nickname, domain) + '/followers.txt'
|
||||||
if os.path.isfile(followersFilename):
|
if os.path.isfile(followersFilename):
|
||||||
with open(followersFilename, 'r') as f:
|
with open(followersFilename, 'r') as f:
|
||||||
followerHandles = f.readlines()
|
followerHandles = f.readlines()
|
||||||
|
|
|
@ -527,8 +527,7 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
os.mkdir(basePath)
|
os.mkdir(basePath)
|
||||||
|
|
||||||
# oldest items first
|
# oldest items first
|
||||||
newswireReverse = \
|
newswireReverse = OrderedDict(sorted(newswire.items(), reverse=False))
|
||||||
OrderedDict(sorted(newswire.items(), reverse=False))
|
|
||||||
|
|
||||||
for dateStr, item in newswireReverse.items():
|
for dateStr, item in newswireReverse.items():
|
||||||
originalDateStr = dateStr
|
originalDateStr = dateStr
|
||||||
|
|
|
@ -28,6 +28,7 @@ from utils import isSuspended
|
||||||
from utils import containsInvalidChars
|
from utils import containsInvalidChars
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
|
from utils import acctDir
|
||||||
from blocking import isBlockedDomain
|
from blocking import isBlockedDomain
|
||||||
from blocking import isBlockedHashtag
|
from blocking import isBlockedHashtag
|
||||||
from filters import isFiltered
|
from filters import isFiltered
|
||||||
|
@ -918,8 +919,7 @@ def _addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# local blogs can potentially be moderated
|
# local blogs can potentially be moderated
|
||||||
moderatedFilename = \
|
moderatedFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + '/.newswiremoderated'
|
||||||
'/.newswiremoderated'
|
|
||||||
if os.path.isfile(moderatedFilename):
|
if os.path.isfile(moderatedFilename):
|
||||||
moderated = True
|
moderated = True
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ __module_group__ = "Calendar"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _notifyOnPostArrival(baseDir: str, nickname: str, domain: str,
|
def _notifyOnPostArrival(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -20,8 +21,7 @@ def _notifyOnPostArrival(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
# check that a following file exists
|
# check that a following file exists
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
followingFilename = baseDir + '/accounts/' + \
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
nickname + '@' + domain + '/following.txt'
|
|
||||||
if not os.path.isfile(followingFilename):
|
if not os.path.isfile(followingFilename):
|
||||||
print("WARN: following.txt doesn't exist for " +
|
print("WARN: following.txt doesn't exist for " +
|
||||||
nickname + '@' + domain)
|
nickname + '@' + domain)
|
||||||
|
@ -33,8 +33,8 @@ def _notifyOnPostArrival(baseDir: str, nickname: str, domain: str,
|
||||||
print('WARN: ' + handle + ' is not in ' + followingFilename)
|
print('WARN: ' + handle + ' is not in ' + followingFilename)
|
||||||
return
|
return
|
||||||
|
|
||||||
notifyOnPostFilename = baseDir + '/accounts/' + \
|
notifyOnPostFilename = \
|
||||||
nickname + '@' + domain + '/notifyOnPost.txt'
|
acctDir(baseDir, nickname, domain) + '/notifyOnPost.txt'
|
||||||
|
|
||||||
# get the contents of the notifyOnPost file, which is
|
# get the contents of the notifyOnPost file, which is
|
||||||
# a set of handles
|
# a set of handles
|
||||||
|
@ -95,7 +95,7 @@ def notifyWhenPersonPosts(baseDir: str, nickname: str, domain: str,
|
||||||
if followingNickname == nickname and followingDomain == domain:
|
if followingNickname == nickname and followingDomain == domain:
|
||||||
return False
|
return False
|
||||||
notifyOnPostFilename = \
|
notifyOnPostFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/notifyOnPost.txt'
|
acctDir(baseDir, nickname, domain) + '/notifyOnPost.txt'
|
||||||
handle = followingNickname + '@' + followingDomain
|
handle = followingNickname + '@' + followingDomain
|
||||||
if not os.path.isfile(notifyOnPostFilename):
|
if not os.path.isfile(notifyOnPostFilename):
|
||||||
# create a new notifyOnPost file
|
# create a new notifyOnPost file
|
||||||
|
|
52
outbox.py
52
outbox.py
|
@ -25,6 +25,7 @@ from utils import dangerousMarkup
|
||||||
from utils import isFeaturedWriter
|
from utils import isFeaturedWriter
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
from utils import acctDir
|
||||||
from blocking import isBlockedDomain
|
from blocking import isBlockedDomain
|
||||||
from blocking import outboxBlock
|
from blocking import outboxBlock
|
||||||
from blocking import outboxUndoBlock
|
from blocking import outboxUndoBlock
|
||||||
|
@ -106,7 +107,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
updatedActorJson = messageJson['object']
|
updatedActorJson = messageJson['object']
|
||||||
# load actor from file
|
# load actor from file
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
print('actorFilename not found: ' + actorFilename)
|
print('actorFilename not found: ' + actorFilename)
|
||||||
return
|
return
|
||||||
|
@ -127,30 +128,31 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
continue
|
continue
|
||||||
if newPropertyValue['type'] != 'PropertyValue':
|
if newPropertyValue['type'] != 'PropertyValue':
|
||||||
continue
|
continue
|
||||||
if 'attachment' in actorJson:
|
if 'attachment' not in actorJson:
|
||||||
found = False
|
continue
|
||||||
for attachIdx in range(len(actorJson['attachment'])):
|
found = False
|
||||||
if actorJson['attachment'][attachIdx]['type'] != \
|
for attachIdx in range(len(actorJson['attachment'])):
|
||||||
'PropertyValue':
|
if actorJson['attachment'][attachIdx]['type'] != \
|
||||||
continue
|
'PropertyValue':
|
||||||
if actorJson['attachment'][attachIdx]['name'] != \
|
continue
|
||||||
newPropertyValue['name']:
|
if actorJson['attachment'][attachIdx]['name'] != \
|
||||||
continue
|
newPropertyValue['name']:
|
||||||
else:
|
continue
|
||||||
if actorJson['attachment'][attachIdx]['value'] != \
|
else:
|
||||||
newPropertyValue['value']:
|
if actorJson['attachment'][attachIdx]['value'] != \
|
||||||
actorJson['attachment'][attachIdx]['value'] = \
|
newPropertyValue['value']:
|
||||||
newPropertyValue['value']
|
actorJson['attachment'][attachIdx]['value'] = \
|
||||||
actorChanged = True
|
newPropertyValue['value']
|
||||||
found = True
|
actorChanged = True
|
||||||
break
|
found = True
|
||||||
if not found:
|
break
|
||||||
actorJson['attachment'].append({
|
if not found:
|
||||||
"name": newPropertyValue['name'],
|
actorJson['attachment'].append({
|
||||||
"type": "PropertyValue",
|
"name": newPropertyValue['name'],
|
||||||
"value": newPropertyValue['value']
|
"type": "PropertyValue",
|
||||||
})
|
"value": newPropertyValue['value']
|
||||||
actorChanged = True
|
})
|
||||||
|
actorChanged = True
|
||||||
# save actor to file
|
# save actor to file
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actorJson, actorFilename)
|
||||||
|
|
52
person.py
52
person.py
|
@ -51,6 +51,7 @@ from utils import hasUsersPath
|
||||||
from utils import getImageExtensions
|
from utils import getImageExtensions
|
||||||
from utils import isImageFile
|
from utils import isImageFile
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
|
from utils import acctDir
|
||||||
from session import createSession
|
from session import createSession
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -153,7 +154,8 @@ def _accountExists(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Returns true if the given account exists
|
"""Returns true if the given account exists
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
return os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain) or \
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
return os.path.isdir(accountDir) or \
|
||||||
os.path.isdir(baseDir + '/deactivated/' + nickname + '@' + domain)
|
os.path.isdir(baseDir + '/deactivated/' + nickname + '@' + domain)
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,8 +445,7 @@ def savePersonQrcode(baseDir: str,
|
||||||
"""Saves a qrcode image for the handle of the person
|
"""Saves a qrcode image for the handle of the person
|
||||||
This helps to transfer onion or i2p handles to a mobile device
|
This helps to transfer onion or i2p handles to a mobile device
|
||||||
"""
|
"""
|
||||||
qrcodeFilename = baseDir + '/accounts/' + \
|
qrcodeFilename = acctDir(baseDir, nickname, domain) + '/qrcode.png'
|
||||||
nickname + '@' + domain + '/qrcode.png'
|
|
||||||
if os.path.isfile(qrcodeFilename):
|
if os.path.isfile(qrcodeFilename):
|
||||||
return
|
return
|
||||||
handle = getFullDomain('@' + nickname + '@' + domain, port)
|
handle = getFullDomain('@' + nickname + '@' + domain, port)
|
||||||
|
@ -492,19 +493,19 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
if not os.path.isdir(baseDir + '/accounts'):
|
if not os.path.isdir(baseDir + '/accounts'):
|
||||||
os.mkdir(baseDir + '/accounts')
|
os.mkdir(baseDir + '/accounts')
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
os.mkdir(baseDir + '/accounts/' + nickname + '@' + domain)
|
if not os.path.isdir(accountDir):
|
||||||
|
os.mkdir(accountDir)
|
||||||
|
|
||||||
if manualFollowerApproval:
|
if manualFollowerApproval:
|
||||||
followDMsFilename = baseDir + '/accounts/' + \
|
followDMsFilename = acctDir(baseDir, nickname, domain) + '/.followDMs'
|
||||||
nickname + '@' + domain + '/.followDMs'
|
|
||||||
with open(followDMsFilename, 'w+') as fFile:
|
with open(followDMsFilename, 'w+') as fFile:
|
||||||
fFile.write('\n')
|
fFile.write('\n')
|
||||||
|
|
||||||
# notify when posts are liked
|
# notify when posts are liked
|
||||||
if nickname != 'news':
|
if nickname != 'news':
|
||||||
notifyLikesFilename = baseDir + '/accounts/' + \
|
notifyLikesFilename = \
|
||||||
nickname + '@' + domain + '/.notifyLikes'
|
acctDir(baseDir, nickname, domain) + '/.notifyLikes'
|
||||||
with open(notifyLikesFilename, 'w+') as nFile:
|
with open(notifyLikesFilename, 'w+') as nFile:
|
||||||
nFile.write('\n')
|
nFile.write('\n')
|
||||||
|
|
||||||
|
@ -514,15 +515,14 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
if nickname != 'news':
|
if nickname != 'news':
|
||||||
if os.path.isfile(baseDir + '/img/default-avatar.png'):
|
if os.path.isfile(baseDir + '/img/default-avatar.png'):
|
||||||
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
copyfile(baseDir + '/img/default-avatar.png',
|
copyfile(baseDir + '/img/default-avatar.png',
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain +
|
accountDir + '/avatar.png')
|
||||||
'/avatar.png')
|
|
||||||
else:
|
else:
|
||||||
newsAvatar = baseDir + '/theme/' + theme + '/icons/avatar_news.png'
|
newsAvatar = baseDir + '/theme/' + theme + '/icons/avatar_news.png'
|
||||||
if os.path.isfile(newsAvatar):
|
if os.path.isfile(newsAvatar):
|
||||||
copyfile(newsAvatar,
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain +
|
copyfile(newsAvatar, accountDir + '/avatar.png')
|
||||||
'/avatar.png')
|
|
||||||
|
|
||||||
defaultProfileImageFilename = baseDir + '/theme/default/image.png'
|
defaultProfileImageFilename = baseDir + '/theme/default/image.png'
|
||||||
if theme:
|
if theme:
|
||||||
|
@ -530,15 +530,15 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
defaultProfileImageFilename = \
|
defaultProfileImageFilename = \
|
||||||
baseDir + '/theme/' + theme + '/image.png'
|
baseDir + '/theme/' + theme + '/image.png'
|
||||||
if os.path.isfile(defaultProfileImageFilename):
|
if os.path.isfile(defaultProfileImageFilename):
|
||||||
copyfile(defaultProfileImageFilename, baseDir +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
'/accounts/' + nickname + '@' + domain + '/image.png')
|
copyfile(defaultProfileImageFilename, accountDir + '/image.png')
|
||||||
defaultBannerFilename = baseDir + '/theme/default/banner.png'
|
defaultBannerFilename = baseDir + '/theme/default/banner.png'
|
||||||
if theme:
|
if theme:
|
||||||
if os.path.isfile(baseDir + '/theme/' + theme + '/banner.png'):
|
if os.path.isfile(baseDir + '/theme/' + theme + '/banner.png'):
|
||||||
defaultBannerFilename = baseDir + '/theme/' + theme + '/banner.png'
|
defaultBannerFilename = baseDir + '/theme/' + theme + '/banner.png'
|
||||||
if os.path.isfile(defaultBannerFilename):
|
if os.path.isfile(defaultBannerFilename):
|
||||||
copyfile(defaultBannerFilename, baseDir + '/accounts/' +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
nickname + '@' + domain + '/banner.png')
|
copyfile(defaultBannerFilename, accountDir + '/banner.png')
|
||||||
if nickname != 'news' and remainingConfigExists:
|
if nickname != 'news' and remainingConfigExists:
|
||||||
registrationsRemaining -= 1
|
registrationsRemaining -= 1
|
||||||
setConfigParam(baseDir, 'registrationsRemaining',
|
setConfigParam(baseDir, 'registrationsRemaining',
|
||||||
|
@ -899,12 +899,10 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if moderator.strip('\n').strip('\r') == nickname:
|
if moderator.strip('\n').strip('\r') == nickname:
|
||||||
return
|
return
|
||||||
|
|
||||||
saltFilename = baseDir + '/accounts/' + \
|
saltFilename = acctDir(baseDir, nickname, domain) + '/.salt'
|
||||||
nickname + '@' + domain + '/.salt'
|
|
||||||
if os.path.isfile(saltFilename):
|
if os.path.isfile(saltFilename):
|
||||||
os.remove(saltFilename)
|
os.remove(saltFilename)
|
||||||
tokenFilename = baseDir + '/accounts/' + \
|
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
||||||
nickname + '@' + domain + '/.token'
|
|
||||||
if os.path.isfile(tokenFilename):
|
if os.path.isfile(tokenFilename):
|
||||||
os.remove(tokenFilename)
|
os.remove(tokenFilename)
|
||||||
|
|
||||||
|
@ -1090,8 +1088,7 @@ def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
|
||||||
snoozeActor: str) -> bool:
|
snoozeActor: str) -> bool:
|
||||||
"""Returns true if the given actor is snoozed
|
"""Returns true if the given actor is snoozed
|
||||||
"""
|
"""
|
||||||
snoozedFilename = baseDir + '/accounts/' + \
|
snoozedFilename = acctDir(baseDir, nickname, domain) + '/snoozed.txt'
|
||||||
nickname + '@' + domain + '/snoozed.txt'
|
|
||||||
if not os.path.isfile(snoozedFilename):
|
if not os.path.isfile(snoozedFilename):
|
||||||
return False
|
return False
|
||||||
if snoozeActor + ' ' not in open(snoozedFilename).read():
|
if snoozeActor + ' ' not in open(snoozedFilename).read():
|
||||||
|
@ -1131,7 +1128,7 @@ def personSnooze(baseDir: str, nickname: str, domain: str,
|
||||||
snoozeActor: str) -> None:
|
snoozeActor: str) -> None:
|
||||||
"""Temporarily ignores the given actor
|
"""Temporarily ignores the given actor
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountDir):
|
if not os.path.isdir(accountDir):
|
||||||
print('ERROR: unknown account ' + accountDir)
|
print('ERROR: unknown account ' + accountDir)
|
||||||
return
|
return
|
||||||
|
@ -1148,7 +1145,7 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
snoozeActor: str) -> None:
|
snoozeActor: str) -> None:
|
||||||
"""Undoes a temporarily ignore of the given actor
|
"""Undoes a temporarily ignore of the given actor
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountDir):
|
if not os.path.isdir(accountDir):
|
||||||
print('ERROR: unknown account ' + accountDir)
|
print('ERROR: unknown account ' + accountDir)
|
||||||
return
|
return
|
||||||
|
@ -1180,8 +1177,7 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
if handle.startswith('@'):
|
if handle.startswith('@'):
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
notesDir = baseDir + '/accounts/' + \
|
notesDir = acctDir(baseDir, nickname, domain) + '/notes'
|
||||||
nickname + '@' + domain + '/notes'
|
|
||||||
if not os.path.isdir(notesDir):
|
if not os.path.isdir(notesDir):
|
||||||
os.mkdir(notesDir)
|
os.mkdir(notesDir)
|
||||||
notesFilename = notesDir + '/' + handle + '.txt'
|
notesFilename = notesDir + '/' + handle + '.txt'
|
||||||
|
|
10
petnames.py
10
petnames.py
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Core"
|
__module_group__ = "Core"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def setPetName(baseDir: str, nickname: str, domain: str,
|
def setPetName(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -22,8 +23,7 @@ def setPetName(baseDir: str, nickname: str, domain: str,
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
if petname.startswith('@'):
|
if petname.startswith('@'):
|
||||||
petname = petname[1:]
|
petname = petname[1:]
|
||||||
petnamesFilename = baseDir + '/accounts/' + \
|
petnamesFilename = acctDir(baseDir, nickname, domain) + '/petnames.txt'
|
||||||
nickname + '@' + domain + '/petnames.txt'
|
|
||||||
entry = petname + ' ' + handle + '\n'
|
entry = petname + ' ' + handle + '\n'
|
||||||
|
|
||||||
# does this entry already exist?
|
# does this entry already exist?
|
||||||
|
@ -63,8 +63,7 @@ def getPetName(baseDir: str, nickname: str, domain: str,
|
||||||
return ''
|
return ''
|
||||||
if handle.startswith('@'):
|
if handle.startswith('@'):
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
petnamesFilename = baseDir + '/accounts/' + \
|
petnamesFilename = acctDir(baseDir, nickname, domain) + '/petnames.txt'
|
||||||
nickname + '@' + domain + '/petnames.txt'
|
|
||||||
|
|
||||||
if not os.path.isfile(petnamesFilename):
|
if not os.path.isfile(petnamesFilename):
|
||||||
return ''
|
return ''
|
||||||
|
@ -91,8 +90,7 @@ def _getPetNameHandle(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if petname.startswith('@'):
|
if petname.startswith('@'):
|
||||||
petname = petname[1:]
|
petname = petname[1:]
|
||||||
petnamesFilename = baseDir + '/accounts/' + \
|
petnamesFilename = acctDir(baseDir, nickname, domain) + '/petnames.txt'
|
||||||
nickname + '@' + domain + '/petnames.txt'
|
|
||||||
|
|
||||||
if not os.path.isfile(petnamesFilename):
|
if not os.path.isfile(petnamesFilename):
|
||||||
return ''
|
return ''
|
||||||
|
|
19
posts.py
19
posts.py
|
@ -59,6 +59,7 @@ from utils import locateNewsArrival
|
||||||
from utils import votesOnNewswireItem
|
from utils import votesOnNewswireItem
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
|
from utils import acctDir
|
||||||
from media import attachMedia
|
from media import attachMedia
|
||||||
from media import replaceYouTube
|
from media import replaceYouTube
|
||||||
from content import limitRepeatedWords
|
from content import limitRepeatedWords
|
||||||
|
@ -775,8 +776,7 @@ def _loadAutoCW(baseDir: str, nickname: str, domain: str) -> []:
|
||||||
"""Loads automatic CWs file and returns a list containing
|
"""Loads automatic CWs file and returns a list containing
|
||||||
the lines of the file
|
the lines of the file
|
||||||
"""
|
"""
|
||||||
filename = baseDir + '/accounts/' + \
|
filename = acctDir(baseDir, nickname, domain) + '/autocw.txt'
|
||||||
nickname + '@' + domain + '/autocw.txt'
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return []
|
return []
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
|
@ -1324,7 +1324,7 @@ def pinPost(baseDir: str, nickname: str, domain: str,
|
||||||
pinnedContent: str) -> None:
|
pinnedContent: str) -> None:
|
||||||
"""Pins the given post Id to the profile of then given account
|
"""Pins the given post Id to the profile of then given account
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
with open(pinnedFilename, 'w+') as pinFile:
|
with open(pinnedFilename, 'w+') as pinFile:
|
||||||
pinFile.write(pinnedContent)
|
pinFile.write(pinnedContent)
|
||||||
|
@ -1333,7 +1333,7 @@ def pinPost(baseDir: str, nickname: str, domain: str,
|
||||||
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
"""Removes pinned content for then given account
|
"""Removes pinned content for then given account
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
os.remove(pinnedFilename)
|
os.remove(pinnedFilename)
|
||||||
|
@ -1344,7 +1344,7 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
||||||
domainFull: str) -> {}:
|
domainFull: str) -> {}:
|
||||||
"""Returns the pinned profile post as json
|
"""Returns the pinned profile post as json
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
pinnedPostJson = {}
|
pinnedPostJson = {}
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
|
@ -1464,8 +1464,7 @@ def _appendCitationsToBlogPost(baseDir: str,
|
||||||
"""
|
"""
|
||||||
# append citations tags, stored in a file
|
# append citations tags, stored in a file
|
||||||
citationsFilename = \
|
citationsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
||||||
nickname + '@' + domain + '/.citations.txt'
|
|
||||||
if not os.path.isfile(citationsFilename):
|
if not os.path.isfile(citationsFilename):
|
||||||
return
|
return
|
||||||
citationsSeparator = '#####'
|
citationsSeparator = '#####'
|
||||||
|
@ -3815,9 +3814,7 @@ def populateRepliesJson(baseDir: str, nickname: str, domain: str,
|
||||||
for boxname in repliesBoxes:
|
for boxname in repliesBoxes:
|
||||||
messageId2 = messageId.replace('\n', '').replace('\r', '')
|
messageId2 = messageId.replace('\n', '').replace('\r', '')
|
||||||
searchFilename = \
|
searchFilename = \
|
||||||
baseDir + \
|
acctDir(baseDir, nickname, domain) + '/' + \
|
||||||
'/accounts/' + nickname + '@' + \
|
|
||||||
domain + '/' + \
|
|
||||||
boxname + '/' + \
|
boxname + '/' + \
|
||||||
messageId2.replace('/', '#') + '.json'
|
messageId2.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
|
@ -4419,7 +4416,7 @@ def postIsMuted(baseDir: str, nickname: str, domain: str,
|
||||||
isMuted = postJsonObject.get('muted')
|
isMuted = postJsonObject.get('muted')
|
||||||
if isMuted is True or isMuted is False:
|
if isMuted is True or isMuted is False:
|
||||||
return isMuted
|
return isMuted
|
||||||
postDir = baseDir + '/accounts/' + nickname + '@' + domain
|
postDir = acctDir(baseDir, nickname, domain)
|
||||||
muteFilename = \
|
muteFilename = \
|
||||||
postDir + '/inbox/' + messageId.replace('/', '#') + '.json.muted'
|
postDir + '/inbox/' + messageId.replace('/', '#') + '.json.muted'
|
||||||
if os.path.isfile(muteFilename):
|
if os.path.isfile(muteFilename):
|
||||||
|
|
7
roles.py
7
roles.py
|
@ -12,6 +12,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _clearRoleStatus(baseDir: str, role: str) -> None:
|
def _clearRoleStatus(baseDir: str, role: str) -> None:
|
||||||
|
@ -98,8 +99,8 @@ def _addRole(baseDir: str, nickname: str, domain: str,
|
||||||
f.write(roleNickname + '\n')
|
f.write(roleNickname + '\n')
|
||||||
else:
|
else:
|
||||||
with open(roleFile, 'w+') as f:
|
with open(roleFile, 'w+') as f:
|
||||||
if os.path.isdir(baseDir + '/accounts/' +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
nickname + '@' + domain):
|
if os.path.isdir(accountDir):
|
||||||
f.write(nickname + '\n')
|
f.write(nickname + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
@ -230,7 +231,7 @@ def setRole(baseDir: str, nickname: str, domain: str,
|
||||||
# avoid giant strings
|
# avoid giant strings
|
||||||
if len(role) > 128:
|
if len(role) > 128:
|
||||||
return False
|
return False
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ from utils import hasObjectDict
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
|
from utils import acctDir
|
||||||
from outbox import postMessageToOutbox
|
from outbox import postMessageToOutbox
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,12 +180,11 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
"""
|
"""
|
||||||
# remove the index
|
# remove the index
|
||||||
scheduleIndexFilename = \
|
scheduleIndexFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/schedule.index'
|
acctDir(baseDir, nickname, domain) + '/schedule.index'
|
||||||
if os.path.isfile(scheduleIndexFilename):
|
if os.path.isfile(scheduleIndexFilename):
|
||||||
os.remove(scheduleIndexFilename)
|
os.remove(scheduleIndexFilename)
|
||||||
# remove the scheduled posts
|
# remove the scheduled posts
|
||||||
scheduledDir = baseDir + '/accounts/' + \
|
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
||||||
nickname + '@' + domain + '/scheduled'
|
|
||||||
if not os.path.isdir(scheduledDir):
|
if not os.path.isdir(scheduledDir):
|
||||||
return
|
return
|
||||||
for scheduledPostFilename in os.listdir(scheduledDir):
|
for scheduledPostFilename in os.listdir(scheduledDir):
|
||||||
|
|
12
shares.py
12
shares.py
|
@ -22,6 +22,7 @@ from utils import getImageExtensions
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
|
from utils import acctDir
|
||||||
from media import processMetaData
|
from media import processMetaData
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,8 +45,7 @@ def removeShare(baseDir: str, nickname: str, domain: str,
|
||||||
displayName: str) -> None:
|
displayName: str) -> None:
|
||||||
"""Removes a share for a person
|
"""Removes a share for a person
|
||||||
"""
|
"""
|
||||||
sharesFilename = baseDir + '/accounts/' + \
|
sharesFilename = acctDir(baseDir, nickname, domain) + '/shares.json'
|
||||||
nickname + '@' + domain + '/shares.json'
|
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
print('ERROR: missing shares.json ' + sharesFilename)
|
print('ERROR: missing shares.json ' + sharesFilename)
|
||||||
return
|
return
|
||||||
|
@ -101,8 +101,7 @@ def addShare(baseDir: str,
|
||||||
duration: str, debug: bool, city: str) -> None:
|
duration: str, debug: bool, city: str) -> None:
|
||||||
"""Adds a new share
|
"""Adds a new share
|
||||||
"""
|
"""
|
||||||
sharesFilename = baseDir + '/accounts/' + \
|
sharesFilename = acctDir(baseDir, nickname, domain) + '/shares.json'
|
||||||
nickname + '@' + domain + '/shares.json'
|
|
||||||
sharesJson = {}
|
sharesJson = {}
|
||||||
if os.path.isfile(sharesFilename):
|
if os.path.isfile(sharesFilename):
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = loadJson(sharesFilename)
|
||||||
|
@ -118,7 +117,7 @@ def addShare(baseDir: str,
|
||||||
moveImage = False
|
moveImage = False
|
||||||
if not imageFilename:
|
if not imageFilename:
|
||||||
sharesImageFilename = \
|
sharesImageFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/upload'
|
acctDir(baseDir, nickname, domain) + '/upload'
|
||||||
formats = getImageExtensions()
|
formats = getImageExtensions()
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
if os.path.isfile(sharesImageFilename + '.' + ext):
|
if os.path.isfile(sharesImageFilename + '.' + ext):
|
||||||
|
@ -257,8 +256,7 @@ def getSharesFeedForPerson(baseDir: str,
|
||||||
domain = getFullDomain(domain, port)
|
domain = getFullDomain(domain, port)
|
||||||
|
|
||||||
handleDomain = removeDomainPort(domain)
|
handleDomain = removeDomainPort(domain)
|
||||||
handle = nickname + '@' + handleDomain
|
sharesFilename = acctDir(baseDir, nickname, handleDomain) + '/shares.json'
|
||||||
sharesFilename = baseDir + '/accounts/' + handle + '/shares.json'
|
|
||||||
|
|
||||||
if headerOnly:
|
if headerOnly:
|
||||||
noOfShares = 0
|
noOfShares = 0
|
||||||
|
|
|
@ -18,6 +18,7 @@ from utils import getDomainFromActor
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getOccupationSkills
|
from utils import getOccupationSkills
|
||||||
from utils import setOccupationSkillsList
|
from utils import setOccupationSkillsList
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> []:
|
def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> []:
|
||||||
|
@ -115,7 +116,7 @@ def setSkillLevel(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if skillLevelPercent < 0 or skillLevelPercent > 100:
|
if skillLevelPercent < 0 or skillLevelPercent > 100:
|
||||||
return False
|
return False
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ def setSkillLevel(baseDir: str, nickname: str, domain: str,
|
||||||
def getSkills(baseDir: str, nickname: str, domain: str) -> []:
|
def getSkills(baseDir: str, nickname: str, domain: str) -> []:
|
||||||
"""Returns the skills for a given person
|
"""Returns the skills for a given person
|
||||||
"""
|
"""
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import isPGPEncrypted
|
from utils import isPGPEncrypted
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
|
from utils import acctDir
|
||||||
from content import htmlReplaceQuoteMarks
|
from content import htmlReplaceQuoteMarks
|
||||||
|
|
||||||
speakerRemoveChars = ('.\n', '. ', ',', ';', '?', '!')
|
speakerRemoveChars = ('.\n', '. ', ',', ';', '?', '!')
|
||||||
|
@ -356,7 +357,7 @@ def getSSMLbox(baseDir: str, path: str,
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
speakerFilename = \
|
speakerFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
acctDir(baseDir, nickname, domain) + '/speaker.json'
|
||||||
if not os.path.isfile(speakerFilename):
|
if not os.path.isfile(speakerFilename):
|
||||||
return None
|
return None
|
||||||
speakerJson = loadJson(speakerFilename)
|
speakerJson = loadJson(speakerFilename)
|
||||||
|
@ -491,7 +492,7 @@ def _postToSpeakerJson(baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
followRequestsExist = False
|
followRequestsExist = False
|
||||||
followRequestsList = []
|
followRequestsList = []
|
||||||
accountsDir = baseDir + '/accounts/' + nickname + '@' + domainFull
|
accountsDir = acctDir(baseDir, nickname, domainFull)
|
||||||
approveFollowsFilename = accountsDir + '/followrequests.txt'
|
approveFollowsFilename = accountsDir + '/followrequests.txt'
|
||||||
if os.path.isfile(approveFollowsFilename):
|
if os.path.isfile(approveFollowsFilename):
|
||||||
with open(approveFollowsFilename, 'r') as fp:
|
with open(approveFollowsFilename, 'r') as fp:
|
||||||
|
@ -544,6 +545,5 @@ def updateSpeaker(baseDir: str, httpPrefix: str,
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, announcingActor,
|
translate, announcingActor,
|
||||||
themeName)
|
themeName)
|
||||||
speakerFilename = \
|
speakerFilename = acctDir(baseDir, nickname, domain) + '/speaker.json'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
|
||||||
saveJson(speakerJson, speakerFilename)
|
saveJson(speakerJson, speakerFilename)
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -57,6 +57,7 @@ from utils import getStatusNumber
|
||||||
from utils import getFollowersOfPerson
|
from utils import getFollowersOfPerson
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
|
from utils import acctDir
|
||||||
from pgp import extractPGPPublicKey
|
from pgp import extractPGPPublicKey
|
||||||
from pgp import pgpPublicKeyUpload
|
from pgp import pgpPublicKeyUpload
|
||||||
from utils import containsPGPPublicKey
|
from utils import containsPGPPublicKey
|
||||||
|
@ -1405,8 +1406,8 @@ def _testFollows():
|
||||||
followPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
followPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
||||||
federationList, False)
|
federationList, False)
|
||||||
|
|
||||||
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
'/following.txt', 'r')
|
f = open(accountDir + '/following.txt', 'r')
|
||||||
domainFound = False
|
domainFound = False
|
||||||
for followingDomain in f:
|
for followingDomain in f:
|
||||||
testDomain = followingDomain.split('@')[1]
|
testDomain = followingDomain.split('@')[1]
|
||||||
|
@ -1440,8 +1441,8 @@ def _testFollows():
|
||||||
followerOfPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
followerOfPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
||||||
federationList, False)
|
federationList, False)
|
||||||
|
|
||||||
f = open(baseDir + '/accounts/' + nickname + '@' + domain +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
'/followers.txt', 'r')
|
f = open(accountDir + '/followers.txt', 'r')
|
||||||
for followerDomain in f:
|
for followerDomain in f:
|
||||||
testDomain = followerDomain.split('@')[1]
|
testDomain = followerDomain.split('@')[1]
|
||||||
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
testDomain = testDomain.replace('\n', '').replace('\r', '')
|
||||||
|
|
6
theme.py
6
theme.py
|
@ -13,6 +13,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import getImageExtensions
|
from utils import getImageExtensions
|
||||||
from utils import copytree
|
from utils import copytree
|
||||||
|
from utils import acctDir
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from shutil import make_archive
|
from shutil import make_archive
|
||||||
from shutil import unpack_archive
|
from shutil import unpack_archive
|
||||||
|
@ -721,9 +722,8 @@ def setNewsAvatar(baseDir: str, name: str,
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
if os.path.isdir(baseDir + '/cache/avatars'):
|
if os.path.isdir(baseDir + '/cache/avatars'):
|
||||||
copyfile(newFilename, filename)
|
copyfile(newFilename, filename)
|
||||||
copyfile(newFilename,
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
baseDir + '/accounts/' +
|
copyfile(newFilename, accountDir + '/avatar.png')
|
||||||
nickname + '@' + domain + '/avatar.png')
|
|
||||||
|
|
||||||
|
|
||||||
def _setClearCacheFlag(baseDir: str) -> None:
|
def _setClearCacheFlag(baseDir: str) -> None:
|
||||||
|
|
36
utils.py
36
utils.py
|
@ -28,13 +28,16 @@ invalidCharacters = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def acctDir(baseDir: str, nickname: str, domain: str) -> str:
|
||||||
|
return baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
|
||||||
|
|
||||||
def isFeaturedWriter(baseDir: str, nickname: str, domain: str) -> bool:
|
def isFeaturedWriter(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Is the given account a featured writer, appearing in the features
|
"""Is the given account a featured writer, appearing in the features
|
||||||
timeline on news instances?
|
timeline on news instances?
|
||||||
"""
|
"""
|
||||||
featuresBlockedFilename = \
|
featuresBlockedFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.nofeatures'
|
||||||
nickname + '@' + domain + '/.nofeatures'
|
|
||||||
return not os.path.isfile(featuresBlockedFilename)
|
return not os.path.isfile(featuresBlockedFilename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,8 +160,7 @@ def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
|
||||||
"""Is the given followed actor dormant, from the standpoint
|
"""Is the given followed actor dormant, from the standpoint
|
||||||
of the given account
|
of the given account
|
||||||
"""
|
"""
|
||||||
lastSeenFilename = \
|
lastSeenFilename = acctDir(baseDir, nickname, domain) + \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
|
||||||
'/lastseen/' + actor.replace('/', '#') + '.txt'
|
'/lastseen/' + actor.replace('/', '#') + '.txt'
|
||||||
|
|
||||||
if not os.path.isfile(lastSeenFilename):
|
if not os.path.isfile(lastSeenFilename):
|
||||||
|
@ -440,8 +442,7 @@ def getFollowersList(baseDir: str,
|
||||||
followFile='following.txt') -> []:
|
followFile='following.txt') -> []:
|
||||||
"""Returns a list of followers for the given account
|
"""Returns a list of followers for the given account
|
||||||
"""
|
"""
|
||||||
filename = \
|
filename = acctDir(baseDir, nickname, domain) + '/' + followFile
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/' + followFile
|
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return []
|
return []
|
||||||
|
@ -950,7 +951,7 @@ def _setDefaultPetName(baseDir: str, nickname: str, domain: str,
|
||||||
This helps especially when using onion or i2p address
|
This helps especially when using onion or i2p address
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
userPath = baseDir + '/accounts/' + nickname + '@' + domain
|
userPath = acctDir(baseDir, nickname, domain)
|
||||||
petnamesFilename = userPath + '/petnames.txt'
|
petnamesFilename = userPath + '/petnames.txt'
|
||||||
|
|
||||||
petnameLookupEntry = followNickname + ' ' + \
|
petnameLookupEntry = followNickname + ' ' + \
|
||||||
|
@ -1180,7 +1181,7 @@ def locatePost(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# search boxes
|
# search boxes
|
||||||
boxes = ('inbox', 'outbox', 'tlblogs')
|
boxes = ('inbox', 'outbox', 'tlblogs')
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain + '/'
|
accountDir = acctDir(baseDir, nickname, domain) + '/'
|
||||||
for boxName in boxes:
|
for boxName in boxes:
|
||||||
postFilename = accountDir + boxName + '/' + postUrl
|
postFilename = accountDir + boxName + '/' + postUrl
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
|
@ -1251,8 +1252,7 @@ def _isReplyToBlogPost(baseDir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
if not isinstance(postJsonObject['object']['inReplyTo'], str):
|
if not isinstance(postJsonObject['object']['inReplyTo'], str):
|
||||||
return False
|
return False
|
||||||
blogsIndexFilename = baseDir + '/accounts/' + \
|
blogsIndexFilename = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
|
||||||
nickname + '@' + domain + '/tlblogs.index'
|
|
||||||
if not os.path.isfile(blogsIndexFilename):
|
if not os.path.isfile(blogsIndexFilename):
|
||||||
return False
|
return False
|
||||||
postId = removeIdEnding(postJsonObject['object']['inReplyTo'])
|
postId = removeIdEnding(postJsonObject['object']['inReplyTo'])
|
||||||
|
@ -1290,8 +1290,7 @@ def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
||||||
"""Returns True if the given post is bookmarked
|
"""Returns True if the given post is bookmarked
|
||||||
"""
|
"""
|
||||||
bookmarksIndexFilename = \
|
bookmarksIndexFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + '/bookmarks.index'
|
||||||
'/bookmarks.index'
|
|
||||||
if os.path.isfile(bookmarksIndexFilename):
|
if os.path.isfile(bookmarksIndexFilename):
|
||||||
bookmarkIndex = postFilename.split('/')[-1] + '\n'
|
bookmarkIndex = postFilename.split('/')[-1] + '\n'
|
||||||
if bookmarkIndex in open(bookmarksIndexFilename).read():
|
if bookmarkIndex in open(bookmarksIndexFilename).read():
|
||||||
|
@ -1626,8 +1625,7 @@ def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None):
|
||||||
def getCachedPostDirectory(baseDir: str, nickname: str, domain: str) -> str:
|
def getCachedPostDirectory(baseDir: str, nickname: str, domain: str) -> str:
|
||||||
"""Returns the directory where the html post cache exists
|
"""Returns the directory where the html post cache exists
|
||||||
"""
|
"""
|
||||||
htmlPostCacheDir = baseDir + '/accounts/' + \
|
htmlPostCacheDir = acctDir(baseDir, nickname, domain) + '/postcache'
|
||||||
nickname + '@' + domain + '/postcache'
|
|
||||||
return htmlPostCacheDir
|
return htmlPostCacheDir
|
||||||
|
|
||||||
|
|
||||||
|
@ -1780,11 +1778,10 @@ def _searchVirtualBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
"""Searches through a virtual box, which is typically an index on the inbox
|
"""Searches through a virtual box, which is typically an index on the inbox
|
||||||
"""
|
"""
|
||||||
indexFilename = \
|
indexFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/' + \
|
acctDir(baseDir, nickname, domain) + '/' + boxName + '.index'
|
||||||
boxName + '.index'
|
|
||||||
if boxName == 'bookmarks':
|
if boxName == 'bookmarks':
|
||||||
boxName = 'inbox'
|
boxName = 'inbox'
|
||||||
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
path = acctDir(baseDir, nickname, domain) + '/' + boxName
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -1833,7 +1830,7 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
"""Search your posts and return a list of the filenames
|
"""Search your posts and return a list of the filenames
|
||||||
containing matching strings
|
containing matching strings
|
||||||
"""
|
"""
|
||||||
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
path = acctDir(baseDir, nickname, domain) + '/' + boxName
|
||||||
# is this a virtual box, such as direct messages?
|
# is this a virtual box, such as direct messages?
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
if os.path.isfile(path + '.index'):
|
if os.path.isfile(path + '.index'):
|
||||||
|
@ -2349,8 +2346,7 @@ def dmAllowedFromDomain(baseDir: str,
|
||||||
a few particular instances that you trust
|
a few particular instances that you trust
|
||||||
"""
|
"""
|
||||||
dmAllowedInstancesFilename = \
|
dmAllowedInstancesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/dmAllowedInstances.txt'
|
||||||
nickname + '@' + domain + '/dmAllowedInstances.txt'
|
|
||||||
if not os.path.isfile(dmAllowedInstancesFilename):
|
if not os.path.isfile(dmAllowedInstancesFilename):
|
||||||
return False
|
return False
|
||||||
if sendingActorDomain + '\n' in open(dmAllowedInstancesFilename).read():
|
if sendingActorDomain + '\n' in open(dmAllowedInstancesFilename).read():
|
||||||
|
|
|
@ -11,6 +11,7 @@ import os
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
|
from utils import acctDir
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ def htmlAccessKeys(cssCache: {}, baseDir: str,
|
||||||
"""Show and edit key shortcuts
|
"""Show and edit key shortcuts
|
||||||
"""
|
"""
|
||||||
accessKeysFilename = \
|
accessKeysFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/accessKeys.json'
|
acctDir(baseDir, nickname, domain) + '/accessKeys.json'
|
||||||
if os.path.isfile(accessKeysFilename):
|
if os.path.isfile(accessKeysFilename):
|
||||||
accessKeysFromFile = loadJson(accessKeysFilename)
|
accessKeysFromFile = loadJson(accessKeysFilename)
|
||||||
if accessKeysFromFile:
|
if accessKeysFromFile:
|
||||||
|
|
|
@ -20,6 +20,7 @@ from utils import loadJson
|
||||||
from utils import weekDayOfMonthStart
|
from utils import weekDayOfMonthStart
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
from utils import acctDir
|
||||||
from happening import getTodaysEvents
|
from happening import getTodaysEvents
|
||||||
from happening import getCalendarEvents
|
from happening import getCalendarEvents
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
@ -104,7 +105,7 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
||||||
monthName: str, actor: str) -> str:
|
monthName: str, actor: str) -> str:
|
||||||
"""Show a day within the calendar
|
"""Show a day within the calendar
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
calendarFile = accountDir + '/.newCalendar'
|
calendarFile = accountDir + '/.newCalendar'
|
||||||
if os.path.isfile(calendarFile):
|
if os.path.isfile(calendarFile):
|
||||||
os.remove(calendarFile)
|
os.remove(calendarFile)
|
||||||
|
|
|
@ -19,6 +19,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import isEditor
|
from utils import isEditor
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
from utils import acctDir
|
||||||
from posts import isModerator
|
from posts import isModerator
|
||||||
from webapp_utils import getRightImageFile
|
from webapp_utils import getRightImageFile
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
@ -337,8 +338,7 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
|
||||||
# create a list of dates for citations
|
# create a list of dates for citations
|
||||||
# these can then be used to re-select checkboxes later
|
# these can then be used to re-select checkboxes later
|
||||||
citationsFilename = \
|
citationsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
||||||
nickname + '@' + domain + '/.citations.txt'
|
|
||||||
citationsSelected = []
|
citationsSelected = []
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
citationsSeparator = '#####'
|
citationsSeparator = '#####'
|
||||||
|
|
|
@ -16,6 +16,7 @@ from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
|
from utils import acctDir
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from webapp_post import individualPostAsHtml
|
from webapp_post import individualPostAsHtml
|
||||||
|
@ -111,8 +112,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
|
||||||
nickname = getNicknameFromActor(actor)
|
nickname = getNicknameFromActor(actor)
|
||||||
domain, port = getDomainFromActor(actor)
|
domain, port = getDomainFromActor(actor)
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
sharesFile = baseDir + '/accounts/' + \
|
sharesFile = acctDir(baseDir, nickname, domain) + '/shares.json'
|
||||||
nickname + '@' + domain + '/shares.json'
|
|
||||||
if not os.path.isfile(sharesFile):
|
if not os.path.isfile(sharesFile):
|
||||||
print('ERROR: no shares file ' + sharesFile)
|
print('ERROR: no shares file ' + sharesFile)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -14,6 +14,7 @@ from utils import getDomainFromActor
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
from utils import getMediaFormats
|
from utils import getMediaFormats
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
|
from utils import acctDir
|
||||||
from webapp_utils import getBannerFile
|
from webapp_utils import getBannerFile
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
|
@ -25,7 +26,7 @@ def _htmlFollowingDataList(baseDir: str, nickname: str,
|
||||||
"""
|
"""
|
||||||
listStr = '<datalist id="followingHandles">\n'
|
listStr = '<datalist id="followingHandles">\n'
|
||||||
followingFilename = \
|
followingFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/following.txt'
|
acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
msg = None
|
msg = None
|
||||||
if os.path.isfile(followingFilename):
|
if os.path.isfile(followingFilename):
|
||||||
with open(followingFilename, 'r') as followingFile:
|
with open(followingFilename, 'r') as followingFile:
|
||||||
|
@ -36,7 +37,7 @@ def _htmlFollowingDataList(baseDir: str, nickname: str,
|
||||||
if msg:
|
if msg:
|
||||||
# include petnames
|
# include petnames
|
||||||
petnamesFilename = \
|
petnamesFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/petnames.txt'
|
acctDir(baseDir, nickname, domain) + '/petnames.txt'
|
||||||
if os.path.isfile(petnamesFilename):
|
if os.path.isfile(petnamesFilename):
|
||||||
followingList = []
|
followingList = []
|
||||||
with open(petnamesFilename, 'r') as petnamesFile:
|
with open(petnamesFilename, 'r') as petnamesFile:
|
||||||
|
@ -403,8 +404,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
citationsStr = ''
|
citationsStr = ''
|
||||||
if endpoint == 'newblog':
|
if endpoint == 'newblog':
|
||||||
citationsFilename = \
|
citationsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/.citations.txt'
|
||||||
nickname + '@' + domain + '/.citations.txt'
|
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
citationsStr = '<div class="container">\n'
|
citationsStr = '<div class="container">\n'
|
||||||
citationsStr += '<p><label class="labels">' + \
|
citationsStr += '<p><label class="labels">' + \
|
||||||
|
|
|
@ -10,6 +10,7 @@ __module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from utils import acctDir
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from happening import dayEventsCheck
|
from happening import dayEventsCheck
|
||||||
|
@ -91,8 +92,7 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
'</span></button></a>'
|
'</span></button></a>'
|
||||||
|
|
||||||
repliesIndexFilename = \
|
repliesIndexFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/tlreplies.index'
|
||||||
nickname + '@' + domain + '/tlreplies.index'
|
|
||||||
if os.path.isfile(repliesIndexFilename):
|
if os.path.isfile(repliesIndexFilename):
|
||||||
tlStr += \
|
tlStr += \
|
||||||
'<a href="' + usersPath + '/tlreplies" tabindex="-1">' + \
|
'<a href="' + usersPath + '/tlreplies" tabindex="-1">' + \
|
||||||
|
|
|
@ -8,14 +8,14 @@ __status__ = "Production"
|
||||||
__module_group__ = "Timeline"
|
__module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def isMinimal(baseDir: str, domain: str, nickname: str) -> bool:
|
def isMinimal(baseDir: str, domain: str, nickname: str) -> bool:
|
||||||
"""Returns true if minimal buttons should be shown
|
"""Returns true if minimal buttons should be shown
|
||||||
for the given account
|
for the given account
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + \
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
nickname + '@' + domain
|
|
||||||
if not os.path.isdir(accountDir):
|
if not os.path.isdir(accountDir):
|
||||||
return True
|
return True
|
||||||
minimalFilename = accountDir + '/.notminimal'
|
minimalFilename = accountDir + '/.notminimal'
|
||||||
|
@ -28,7 +28,7 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||||
minimal: bool) -> None:
|
minimal: bool) -> None:
|
||||||
"""Sets whether an account should display minimal buttons
|
"""Sets whether an account should display minimal buttons
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountDir):
|
if not os.path.isdir(accountDir):
|
||||||
return
|
return
|
||||||
minimalFilename = accountDir + '/.notminimal'
|
minimalFilename = accountDir + '/.notminimal'
|
||||||
|
|
|
@ -19,6 +19,7 @@ from utils import removeHtml
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import isFeaturedWriter
|
from utils import isFeaturedWriter
|
||||||
|
from utils import acctDir
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
from follow import isFollowerOfPerson
|
from follow import isFollowerOfPerson
|
||||||
from follow import isFollowingActor
|
from follow import isFollowingActor
|
||||||
|
@ -395,7 +396,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
personNotes = ''
|
personNotes = ''
|
||||||
if originPathStr == '/users/' + nickname:
|
if originPathStr == '/users/' + nickname:
|
||||||
personNotesFilename = \
|
personNotesFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
'/notes/' + handle + '.txt'
|
'/notes/' + handle + '.txt'
|
||||||
if os.path.isfile(personNotesFilename):
|
if os.path.isfile(personNotesFilename):
|
||||||
with open(personNotesFilename, 'r') as fp:
|
with open(personNotesFilename, 'r') as fp:
|
||||||
|
|
|
@ -45,6 +45,7 @@ from utils import removeIdEnding
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import isEventPost
|
from utils import isEventPost
|
||||||
|
from utils import acctDir
|
||||||
from content import limitRepeatedWords
|
from content import limitRepeatedWords
|
||||||
from content import replaceEmojiFromTags
|
from content import replaceEmojiFromTags
|
||||||
from content import htmlReplaceQuoteMarks
|
from content import htmlReplaceQuoteMarks
|
||||||
|
@ -1439,7 +1440,7 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
|
|
||||||
# whether to show a like button
|
# whether to show a like button
|
||||||
hideLikeButtonFile = \
|
hideLikeButtonFile = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/.hideLikeButton'
|
acctDir(baseDir, nickname, domain) + '/.hideLikeButton'
|
||||||
showLikeButton = True
|
showLikeButton = True
|
||||||
if os.path.isfile(hideLikeButtonFile):
|
if os.path.isfile(hideLikeButtonFile):
|
||||||
showLikeButton = False
|
showLikeButton = False
|
||||||
|
|
|
@ -22,6 +22,7 @@ from utils import removeHtml
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
|
from utils import acctDir
|
||||||
from skills import getSkills
|
from skills import getSkills
|
||||||
from theme import getThemesList
|
from theme import getThemesList
|
||||||
from person import personBoxJson
|
from person import personBoxJson
|
||||||
|
@ -592,8 +593,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
|
|
||||||
# are there any follow requests?
|
# are there any follow requests?
|
||||||
followRequestsFilename = \
|
followRequestsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/followrequests.txt'
|
||||||
nickname + '@' + domain + '/followrequests.txt'
|
|
||||||
if os.path.isfile(followRequestsFilename):
|
if os.path.isfile(followRequestsFilename):
|
||||||
with open(followRequestsFilename, 'r') as f:
|
with open(followRequestsFilename, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
@ -679,7 +679,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
'://' + domainFull + '/users/')
|
'://' + domainFull + '/users/')
|
||||||
|
|
||||||
# get pinned post content
|
# get pinned post content
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
pinnedContent = None
|
pinnedContent = None
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
|
@ -1392,8 +1392,7 @@ def _htmlEditProfileGitProjects(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
gitProjectsStr = ''
|
gitProjectsStr = ''
|
||||||
gitProjectsFilename = \
|
gitProjectsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/gitprojects.txt'
|
||||||
nickname + '@' + domain + '/gitprojects.txt'
|
|
||||||
if os.path.isfile(gitProjectsFilename):
|
if os.path.isfile(gitProjectsFilename):
|
||||||
with open(gitProjectsFilename, 'r') as gitProjectsFile:
|
with open(gitProjectsFilename, 'r') as gitProjectsFile:
|
||||||
gitProjectsStr = gitProjectsFile.read()
|
gitProjectsStr = gitProjectsFile.read()
|
||||||
|
@ -1419,55 +1418,49 @@ def _htmlEditProfileFiltering(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
filterStr = ''
|
filterStr = ''
|
||||||
filterFilename = \
|
filterFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/filters.txt'
|
acctDir(baseDir, nickname, domain) + '/filters.txt'
|
||||||
if os.path.isfile(filterFilename):
|
if os.path.isfile(filterFilename):
|
||||||
with open(filterFilename, 'r') as filterfile:
|
with open(filterFilename, 'r') as filterfile:
|
||||||
filterStr = filterfile.read()
|
filterStr = filterfile.read()
|
||||||
|
|
||||||
switchStr = ''
|
switchStr = ''
|
||||||
switchFilename = \
|
switchFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/replacewords.txt'
|
||||||
nickname + '@' + domain + '/replacewords.txt'
|
|
||||||
if os.path.isfile(switchFilename):
|
if os.path.isfile(switchFilename):
|
||||||
with open(switchFilename, 'r') as switchfile:
|
with open(switchFilename, 'r') as switchfile:
|
||||||
switchStr = switchfile.read()
|
switchStr = switchfile.read()
|
||||||
|
|
||||||
autoTags = ''
|
autoTags = ''
|
||||||
autoTagsFilename = \
|
autoTagsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/autotags.txt'
|
||||||
nickname + '@' + domain + '/autotags.txt'
|
|
||||||
if os.path.isfile(autoTagsFilename):
|
if os.path.isfile(autoTagsFilename):
|
||||||
with open(autoTagsFilename, 'r') as autoTagsFile:
|
with open(autoTagsFilename, 'r') as autoTagsFile:
|
||||||
autoTags = autoTagsFile.read()
|
autoTags = autoTagsFile.read()
|
||||||
|
|
||||||
autoCW = ''
|
autoCW = ''
|
||||||
autoCWFilename = \
|
autoCWFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/autocw.txt'
|
||||||
nickname + '@' + domain + '/autocw.txt'
|
|
||||||
if os.path.isfile(autoCWFilename):
|
if os.path.isfile(autoCWFilename):
|
||||||
with open(autoCWFilename, 'r') as autoCWFile:
|
with open(autoCWFilename, 'r') as autoCWFile:
|
||||||
autoCW = autoCWFile.read()
|
autoCW = autoCWFile.read()
|
||||||
|
|
||||||
blockedStr = ''
|
blockedStr = ''
|
||||||
blockedFilename = \
|
blockedFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/blocking.txt'
|
||||||
nickname + '@' + domain + '/blocking.txt'
|
|
||||||
if os.path.isfile(blockedFilename):
|
if os.path.isfile(blockedFilename):
|
||||||
with open(blockedFilename, 'r') as blockedfile:
|
with open(blockedFilename, 'r') as blockedfile:
|
||||||
blockedStr = blockedfile.read()
|
blockedStr = blockedfile.read()
|
||||||
|
|
||||||
dmAllowedInstancesStr = ''
|
dmAllowedInstancesStr = ''
|
||||||
dmAllowedInstancesFilename = \
|
dmAllowedInstancesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/dmAllowedInstances.txt'
|
||||||
nickname + '@' + domain + '/dmAllowedInstances.txt'
|
|
||||||
if os.path.isfile(dmAllowedInstancesFilename):
|
if os.path.isfile(dmAllowedInstancesFilename):
|
||||||
with open(dmAllowedInstancesFilename, 'r') as dmAllowedInstancesFile:
|
with open(dmAllowedInstancesFilename, 'r') as dmAllowedInstancesFile:
|
||||||
dmAllowedInstancesStr = dmAllowedInstancesFile.read()
|
dmAllowedInstancesStr = dmAllowedInstancesFile.read()
|
||||||
|
|
||||||
allowedInstancesStr = ''
|
allowedInstancesStr = ''
|
||||||
allowedInstancesFilename = \
|
allowedInstancesFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/allowedinstances.txt'
|
||||||
nickname + '@' + domain + '/allowedinstances.txt'
|
|
||||||
if os.path.isfile(allowedInstancesFilename):
|
if os.path.isfile(allowedInstancesFilename):
|
||||||
with open(allowedInstancesFilename, 'r') as allowedInstancesFile:
|
with open(allowedInstancesFilename, 'r') as allowedInstancesFile:
|
||||||
allowedInstancesStr = allowedInstancesFile.read()
|
allowedInstancesStr = allowedInstancesFile.read()
|
||||||
|
@ -1481,8 +1474,7 @@ def _htmlEditProfileFiltering(baseDir: str, nickname: str, domain: str,
|
||||||
translate['City for spoofed GPS image metadata'] + \
|
translate['City for spoofed GPS image metadata'] + \
|
||||||
'</label><br>\n'
|
'</label><br>\n'
|
||||||
|
|
||||||
cityFilename = baseDir + '/accounts/' + \
|
cityFilename = acctDir(baseDir, nickname, domain) + '/city.txt'
|
||||||
nickname + '@' + domain + '/city.txt'
|
|
||||||
if os.path.isfile(cityFilename):
|
if os.path.isfile(cityFilename):
|
||||||
with open(cityFilename, 'r') as fp:
|
with open(cityFilename, 'r') as fp:
|
||||||
city = fp.read().replace('\n', '')
|
city = fp.read().replace('\n', '')
|
||||||
|
@ -1907,8 +1899,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
return ''
|
return ''
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
|
||||||
actorFilename = \
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@ -1961,17 +1952,14 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
elif actorJson['type'] == 'Group':
|
elif actorJson['type'] == 'Group':
|
||||||
isGroup = 'checked'
|
isGroup = 'checked'
|
||||||
isBot = ''
|
isBot = ''
|
||||||
if os.path.isfile(baseDir + '/accounts/' +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
nickname + '@' + domain + '/.followDMs'):
|
if os.path.isfile(accountDir + '/.followDMs'):
|
||||||
followDMs = 'checked'
|
followDMs = 'checked'
|
||||||
if os.path.isfile(baseDir + '/accounts/' +
|
if os.path.isfile(accountDir + '/.removeTwitter'):
|
||||||
nickname + '@' + domain + '/.removeTwitter'):
|
|
||||||
removeTwitter = 'checked'
|
removeTwitter = 'checked'
|
||||||
if os.path.isfile(baseDir + '/accounts/' +
|
if os.path.isfile(accountDir + '/.notifyLikes'):
|
||||||
nickname + '@' + domain + '/.notifyLikes'):
|
|
||||||
notifyLikes = 'checked'
|
notifyLikes = 'checked'
|
||||||
if os.path.isfile(baseDir + '/accounts/' +
|
if os.path.isfile(accountDir + '/.hideLikeButton'):
|
||||||
nickname + '@' + domain + '/.hideLikeButton'):
|
|
||||||
hideLikeButton = 'checked'
|
hideLikeButton = 'checked'
|
||||||
|
|
||||||
mediaInstance = getConfigParam(baseDir, "mediaInstance")
|
mediaInstance = getConfigParam(baseDir, "mediaInstance")
|
||||||
|
|
|
@ -10,6 +10,7 @@ __module_group__ = "Web Interface"
|
||||||
import os
|
import os
|
||||||
from question import isQuestion
|
from question import isQuestion
|
||||||
from utils import removeIdEnding
|
from utils import removeIdEnding
|
||||||
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def insertQuestion(baseDir: str, translate: {},
|
def insertQuestion(baseDir: str, translate: {},
|
||||||
|
@ -30,7 +31,7 @@ def insertQuestion(baseDir: str, translate: {},
|
||||||
pageNumberStr = '?page=' + str(pageNumber)
|
pageNumberStr = '?page=' + str(pageNumber)
|
||||||
|
|
||||||
votesFilename = \
|
votesFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/questions.txt'
|
acctDir(baseDir, nickname, domain) + '/questions.txt'
|
||||||
|
|
||||||
showQuestionResults = False
|
showQuestionResults = False
|
||||||
if os.path.isfile(votesFilename):
|
if os.path.isfile(votesFilename):
|
||||||
|
|
|
@ -23,6 +23,7 @@ from utils import isPublicPost
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
from utils import searchBoxPosts
|
from utils import searchBoxPosts
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
|
from utils import acctDir
|
||||||
from skills import noOfActorSkills
|
from skills import noOfActorSkills
|
||||||
from skills import getSkillsFromList
|
from skills import getSkillsFromList
|
||||||
from categories import getHashtagCategory
|
from categories import getHashtagCategory
|
||||||
|
@ -658,7 +659,8 @@ def htmlHashtagSearch(cssCache: {},
|
||||||
|
|
||||||
# check that the directory for the nickname exists
|
# check that the directory for the nickname exists
|
||||||
if nickname:
|
if nickname:
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + nickname + '@' + domain):
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
if not os.path.isdir(accountDir):
|
||||||
nickname = None
|
nickname = None
|
||||||
|
|
||||||
# read the index
|
# read the index
|
||||||
|
@ -835,8 +837,8 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
# check that the directory for the nickname exists
|
# check that the directory for the nickname exists
|
||||||
if nickname:
|
if nickname:
|
||||||
if not os.path.isdir(baseDir + '/accounts/' +
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
nickname + '@' + domain):
|
if not os.path.isdir(accountDir):
|
||||||
nickname = None
|
nickname = None
|
||||||
|
|
||||||
# read the index
|
# read the index
|
||||||
|
|
|
@ -15,6 +15,7 @@ from utils import getConfigParam
|
||||||
from utils import getFullDomain
|
from utils import getFullDomain
|
||||||
from utils import isEditor
|
from utils import isEditor
|
||||||
from utils import removeIdEnding
|
from utils import removeIdEnding
|
||||||
|
from utils import acctDir
|
||||||
from follow import followerApprovalActive
|
from follow import followerApprovalActive
|
||||||
from person import isPersonSnoozed
|
from person import isPersonSnoozed
|
||||||
from markdown import markdownToHtml
|
from markdown import markdownToHtml
|
||||||
|
@ -364,7 +365,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
|
|
||||||
timelineStartTime = time.time()
|
timelineStartTime = time.time()
|
||||||
|
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
|
||||||
# should the calendar icon be highlighted?
|
# should the calendar icon be highlighted?
|
||||||
newCalendarEvent = False
|
newCalendarEvent = False
|
||||||
|
@ -498,8 +499,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
# show an icon for new follow approvals
|
# show an icon for new follow approvals
|
||||||
followApprovals = ''
|
followApprovals = ''
|
||||||
followRequestsFilename = \
|
followRequestsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
acctDir(baseDir, nickname, domain) + '/followrequests.txt'
|
||||||
nickname + '@' + domain + '/followrequests.txt'
|
|
||||||
if os.path.isfile(followRequestsFilename):
|
if os.path.isfile(followRequestsFilename):
|
||||||
with open(followRequestsFilename, 'r') as f:
|
with open(followRequestsFilename, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
|
|
@ -16,6 +16,7 @@ from utils import getProtocolPrefixes
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
|
from utils import acctDir
|
||||||
from cache import storePersonInCache
|
from cache import storePersonInCache
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from content import replaceEmojiFromTags
|
from content import replaceEmojiFromTags
|
||||||
|
@ -321,7 +322,7 @@ def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Returns true if there are posts scheduled to be delivered
|
"""Returns true if there are posts scheduled to be delivered
|
||||||
"""
|
"""
|
||||||
scheduleIndexFilename = \
|
scheduleIndexFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/schedule.index'
|
acctDir(baseDir, nickname, domain) + '/schedule.index'
|
||||||
if not os.path.isfile(scheduleIndexFilename):
|
if not os.path.isfile(scheduleIndexFilename):
|
||||||
return False
|
return False
|
||||||
if '#users#' in open(scheduleIndexFilename).read():
|
if '#users#' in open(scheduleIndexFilename).read():
|
||||||
|
@ -424,30 +425,30 @@ def _getImageFile(baseDir: str, name: str, directory: str,
|
||||||
|
|
||||||
def getBannerFile(baseDir: str,
|
def getBannerFile(baseDir: str,
|
||||||
nickname: str, domain: str, theme: str) -> (str, str):
|
nickname: str, domain: str, theme: str) -> (str, str):
|
||||||
return _getImageFile(baseDir, 'banner',
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain,
|
return _getImageFile(baseDir, 'banner', accountDir,
|
||||||
nickname, domain, theme)
|
nickname, domain, theme)
|
||||||
|
|
||||||
|
|
||||||
def getSearchBannerFile(baseDir: str,
|
def getSearchBannerFile(baseDir: str,
|
||||||
nickname: str, domain: str, theme: str) -> (str, str):
|
nickname: str, domain: str, theme: str) -> (str, str):
|
||||||
return _getImageFile(baseDir, 'search_banner',
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain,
|
return _getImageFile(baseDir, 'search_banner', accountDir,
|
||||||
nickname, domain, theme)
|
nickname, domain, theme)
|
||||||
|
|
||||||
|
|
||||||
def getLeftImageFile(baseDir: str,
|
def getLeftImageFile(baseDir: str,
|
||||||
nickname: str, domain: str, theme: str) -> (str, str):
|
nickname: str, domain: str, theme: str) -> (str, str):
|
||||||
return _getImageFile(baseDir, 'left_col_image',
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain,
|
return _getImageFile(baseDir, 'left_col_image', accountDir,
|
||||||
nickname, domain, theme)
|
nickname, domain, theme)
|
||||||
|
|
||||||
|
|
||||||
def getRightImageFile(baseDir: str,
|
def getRightImageFile(baseDir: str,
|
||||||
nickname: str, domain: str, theme: str) -> (str, str):
|
nickname: str, domain: str, theme: str) -> (str, str):
|
||||||
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
return _getImageFile(baseDir, 'right_col_image',
|
return _getImageFile(baseDir, 'right_col_image',
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain,
|
accountDir, nickname, domain, theme)
|
||||||
nickname, domain, theme)
|
|
||||||
|
|
||||||
|
|
||||||
def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
|
def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import os
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
|
from utils import acctDir
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from markdown import markdownToHtml
|
from markdown import markdownToHtml
|
||||||
|
@ -19,7 +20,7 @@ from markdown import markdownToHtml
|
||||||
def isWelcomeScreenComplete(baseDir: str, nickname: str, domain: str) -> bool:
|
def isWelcomeScreenComplete(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
"""Returns true if the welcome screen is complete for the given account
|
"""Returns true if the welcome screen is complete for the given account
|
||||||
"""
|
"""
|
||||||
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
accountPath = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
return
|
return
|
||||||
completeFilename = accountPath + '/.welcome_complete'
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
|
@ -30,7 +31,7 @@ def welcomeScreenIsComplete(baseDir: str,
|
||||||
nickname: str, domain: str) -> None:
|
nickname: str, domain: str) -> None:
|
||||||
"""Indicates that the welcome screen has been shown for a given account
|
"""Indicates that the welcome screen has been shown for a given account
|
||||||
"""
|
"""
|
||||||
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
accountPath = acctDir(baseDir, nickname, domain)
|
||||||
if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
return
|
return
|
||||||
completeFilename = accountPath + '/.welcome_complete'
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
|
|
|
@ -14,6 +14,7 @@ from utils import loadJson
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import getImageExtensions
|
from utils import getImageExtensions
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
|
from utils import acctDir
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from markdown import markdownToHtml
|
from markdown import markdownToHtml
|
||||||
|
@ -69,7 +70,7 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
|
||||||
# get the url of the avatar
|
# get the url of the avatar
|
||||||
for ext in getImageExtensions():
|
for ext in getImageExtensions():
|
||||||
avatarFilename = \
|
avatarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/avatar.' + ext
|
acctDir(baseDir, nickname, domain) + '/avatar.' + ext
|
||||||
if os.path.isfile(avatarFilename):
|
if os.path.isfile(avatarFilename):
|
||||||
break
|
break
|
||||||
avatarUrl = \
|
avatarUrl = \
|
||||||
|
@ -97,7 +98,7 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
|
||||||
'name="previewAvatar">' + translate['Preview'] + '</button> '
|
'name="previewAvatar">' + translate['Preview'] + '</button> '
|
||||||
profileForm += '</center>\n'
|
profileForm += '</center>\n'
|
||||||
|
|
||||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
actorFilename = acctDir(baseDir, nickname, domain) + '.json'
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
displayNickname = actorJson['name']
|
displayNickname = actorJson['name']
|
||||||
profileForm += '<div class="container">\n'
|
profileForm += '<div class="container">\n'
|
||||||
|
|
Loading…
Reference in New Issue