Only apply to public posts

main
Bob Mottram 2021-01-24 18:35:42 +00:00
parent 11f9572457
commit 652394a739
2 changed files with 20 additions and 5 deletions

View File

@ -69,6 +69,7 @@ from person import canRemovePost
from person import personSnooze
from person import personUnsnooze
from posts import pinPost
from posts import unpinPost
from posts import isModerator
from posts import mutePost
from posts import unmutePost
@ -12226,12 +12227,17 @@ class PubServer(BaseHTTPRequestHandler):
else:
privateEvent = True
if not fields.get('pinToProfile'):
pinToProfile = False
else:
pinToProfile = True
if postType == 'newpost':
if not fields.get('pinToProfile'):
pinToProfile = False
else:
pinToProfile = True
# is the post message empty?
if not fields['message']:
# remove the pinned content from profile screen
unpinPost(self.server.baseDir,
nickname, self.server.domain)
messageJson = \
createPublicPost(self.server.baseDir,
nickname,

View File

@ -1285,6 +1285,15 @@ def pinPost(baseDir: str, nickname: str, domain: str,
pinFile.close()
def unpinPost(baseDir: str, nickname: str, domain: str) -> None:
"""Removes pinned content for then given account
"""
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
pinnedFilename = accountDir + '/pinToProfile.txt'
if os.path.isfile(pinnedFilename):
os.remove(pinnedFilename)
def createPublicPost(baseDir: str,
nickname: str, domain: str, port: int, httpPrefix: str,
content: str, followersOnly: bool, saveToFile: bool,