mirror of https://gitlab.com/bashrc2/epicyon
Move set minimal function out of daemon
parent
dd2f918294
commit
ec7f86394c
19
daemon.py
19
daemon.py
|
@ -139,6 +139,7 @@ from blog import htmlBlogView
|
|||
from blog import htmlBlogPage
|
||||
from blog import htmlBlogPost
|
||||
from blog import htmlEditBlog
|
||||
from webapp_utils import setMinimal
|
||||
from webapp_utils import isMinimal
|
||||
from webapp_utils import getAvatarImageUrl
|
||||
from webapp_utils import htmlHashtagBlocked
|
||||
|
@ -364,21 +365,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
str(client_address))
|
||||
pass
|
||||
|
||||
def _setMinimal(self, nickname: str, minimal: bool) -> None:
|
||||
"""Sets whether an account should display minimal buttons
|
||||
"""
|
||||
accountDir = self.server.baseDir + '/accounts/' + \
|
||||
nickname + '@' + self.server.domain
|
||||
if not os.path.isdir(accountDir):
|
||||
return
|
||||
minimalFilename = accountDir + '/.notminimal'
|
||||
minimalFileExists = os.path.isfile(minimalFilename)
|
||||
if minimal and minimalFileExists:
|
||||
os.remove(minimalFilename)
|
||||
elif not minimal and not minimalFileExists:
|
||||
with open(minimalFilename, 'w+') as fp:
|
||||
fp.write('\n')
|
||||
|
||||
def _sendReplyToQuestion(self, nickname: str, messageId: str,
|
||||
answer: str) -> None:
|
||||
"""Sends a reply to a question
|
||||
|
@ -12033,7 +12019,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname = nickname.split('/')[0]
|
||||
notMin = not isMinimal(self.server.baseDir,
|
||||
self.server.domain, nickname)
|
||||
self._setMinimal(nickname, notMin)
|
||||
setMinimal(self.server.baseDir,
|
||||
self.server.domain, nickname, notMin)
|
||||
if not (self.server.mediaInstance or
|
||||
self.server.blogsInstance):
|
||||
self.path = '/users/' + nickname + '/inbox'
|
||||
|
|
|
@ -1372,3 +1372,19 @@ def isMinimal(baseDir: str, domain: str, nickname: str) -> bool:
|
|||
if os.path.isfile(minimalFilename):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||
minimal: bool) -> None:
|
||||
"""Sets whether an account should display minimal buttons
|
||||
"""
|
||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
||||
if not os.path.isdir(accountDir):
|
||||
return
|
||||
minimalFilename = accountDir + '/.notminimal'
|
||||
minimalFileExists = os.path.isfile(minimalFilename)
|
||||
if minimal and minimalFileExists:
|
||||
os.remove(minimalFilename)
|
||||
elif not minimal and not minimalFileExists:
|
||||
with open(minimalFilename, 'w+') as fp:
|
||||
fp.write('\n')
|
||||
|
|
Loading…
Reference in New Issue