diff --git a/utils.py b/utils.py index 15e27b56..6bb11075 100644 --- a/utils.py +++ b/utils.py @@ -425,6 +425,17 @@ def noOfActiveAccountsMonthly(baseDir: str,months: int) -> bool: accountCtr+=1 return accountCtr +def isPublicPostFromUrl(baseDir: str,nickname: str,domain: str,postUrl: str) -> bool: + """Returns whether the given url is a public post + """ + postFilename=locatePost(baseDir,nickname,domain,postUrl) + if not postFilename: + return False + postJsonObject=loadJson(postFilename,1) + if not postJsonObject: + return False + return isPublicPost(postJsonObject) + def isPublicPost(postJsonObject: {}) -> bool: """Returns true if the given post is public """ diff --git a/webinterface.py b/webinterface.py index 85445a10..8249d048 100644 --- a/webinterface.py +++ b/webinterface.py @@ -25,6 +25,7 @@ from utils import getDomainFromActor from utils import locatePost from utils import noOfAccounts from utils import isPublicPost +from utils import isPublicPostFromUrl from utils import getDisplayName from utils import getCachedPostDirectory from utils import getCachedPostFilename @@ -934,11 +935,15 @@ def htmlNewPost(mediaInstance: bool,translate: {}, \ baseDir: str,httpPrefix: str, \ path: str,inReplyTo: str, \ mentions: [], \ - reportUrl: str,pageNumber: int) -> str: + reportUrl: str,pageNumber: int, \ + nickname: str,domain: str) -> str: """New post screen - """ + """ iconsDir=getIconsDir(baseDir) replyStr='' + + showPublicOnDropdown=True + if not path.endswith('/newshare'): if not path.endswith('/newreport'): if not inReplyTo: @@ -946,6 +951,17 @@ def htmlNewPost(mediaInstance: bool,translate: {}, \ else: newPostText='

'+translate['Write your reply to']+' '+translate['this post']+'

' replyStr='' + + # if replying to a non-public post then also make this post non-public + if not isPublicPostFromUrl(baseDir,nickname,domain,inReplyTo): + newPostPath=path + if '?' in newPostPath: + newPostPath=newPostPath.split('?')[0] + if newPostPath.endswith('/newpost'): + path=path.replace('/newpost','/newfollowers') + elif newPostPath.endswith('/newunlisted'): + path=path.replace('/newunlisted','/newfollowers') + showPublicOnDropdown=False else: newPostText= \ '

'+translate['Write your report below.']+'

' @@ -1106,7 +1122,8 @@ def htmlNewPost(mediaInstance: bool,translate: {}, \ dropDownContent='' if not reportUrl: dropDownContent+='