From 0fc18cc7dd8278fadc689780fac29857e37a27dd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 3 Nov 2021 11:25:26 +0000 Subject: [PATCH] Tidying --- daemon.py | 6 ++---- utils.py | 9 +++++++++ webapp_create_post.py | 9 +++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/daemon.py b/daemon.py index 0f50cf71e..3eb96e9ba 100644 --- a/daemon.py +++ b/daemon.py @@ -238,6 +238,7 @@ from categories import updateHashtagCategories from languages import getActorLanguages from languages import setActorLanguages from like import updateLikesCollection +from utils import getNewPostEndpoints from utils import malformedCiphertext from utils import hasActor from utils import setReplyIntervalHours @@ -11893,10 +11894,7 @@ class PubServer(BaseHTTPRequestHandler): isNewPostEndpoint = False if '/users/' in path and '/new' in path: # Various types of new post in the web interface - newPostEnd = ('newpost', 'newblog', 'newunlisted', - 'newfollowers', 'newdm', 'newreminder', - 'newreport', 'newquestion', - 'newshare', 'newwanted') + newPostEnd = getNewPostEndpoints() for postType in newPostEnd: if path.endswith('/' + postType): isNewPostEndpoint = True diff --git a/utils.py b/utils.py index 5ec417ef2..0a47f7919 100644 --- a/utils.py +++ b/utils.py @@ -3145,3 +3145,12 @@ def hasObjectString(postJsonObject: {}, debug: bool) -> bool: if debug: print('No object field within post ' + postJsonObject['id']) return False + + +def getNewPostEndpoints() -> []: + """Returns a list of endpoints for new posts + """ + return ( + 'newpost', 'newblog', 'newunlisted', 'newfollowers', 'newdm', + 'newreminder', 'newreport', 'newquestion', 'newshare', 'newwanted' + ) diff --git a/webapp_create_post.py b/webapp_create_post.py index ace3a47ce..8de72c025 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -8,6 +8,7 @@ __status__ = "Production" __module_group__ = "Web Interface" import os +from utils import getNewPostEndpoints from utils import isPublicPostFromUrl from utils import getNicknameFromActor from utils import getDomainFromActor @@ -289,14 +290,10 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, if '?' in path: path = path.split('?')[0] - newPostEndpoints = ( - '/newreport', '/newpost', '/newblog', '/newshare', - '/newunlisted', '/newwanted', '/newreminder', - '/newfollowers', '/newdm' - ) + newPostEndpoints = getNewPostEndpoints() pathBase = path for newPostReplace in newPostEndpoints: - pathBase = pathBase.replace(newPostReplace, '') + pathBase = pathBase.replace('/' + newPostReplace, '') newPostImageSection = '
' newPostImageSection += \