Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 11:20:57 +00:00
parent f1370531ab
commit 48f51887b8
18 changed files with 95 additions and 94 deletions

View File

@ -10,7 +10,7 @@ __module_group__ = "ActivityPub"
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_group_type from utils import has_group_type
from utils import remove_domain_port from utils import remove_domain_port
from utils import removeIdEnding from utils import remove_id_ending
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import getStatusNumber from utils import getStatusNumber
@ -408,7 +408,7 @@ def outboxUndoAnnounce(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s undo announce request arrived in outbox') print('DEBUG: c2s undo announce request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = remove_id_ending(message_json['object']['object'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageId) post_filename = locate_post(base_dir, nickname, domain, messageId)
if not post_filename: if not post_filename:

View File

@ -24,7 +24,7 @@ from utils import fileLastModified
from utils import setConfigParam from utils import setConfigParam
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import isEvil from utils import isEvil
from utils import locate_post from utils import locate_post
from utils import evilIncarnate from utils import evilIncarnate
@ -432,7 +432,7 @@ def outboxBlock(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s block request arrived in outbox') print('DEBUG: c2s block request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
if debug: if debug:
print('DEBUG: c2s block object is not a status') print('DEBUG: c2s block object is not a status')
@ -488,7 +488,7 @@ def outboxUndoBlock(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s undo block request arrived in outbox') print('DEBUG: c2s undo block request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = remove_id_ending(message_json['object']['object'])
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
if debug: if debug:
print('DEBUG: c2s undo block object is not a status') print('DEBUG: c2s undo block object is not a status')
@ -541,7 +541,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj = post_json_object['object'] postJsonObj = post_json_object['object']
else: else:
if has_object_string(post_json_object, debug): if has_object_string(post_json_object, debug):
alsoUpdatePostId = removeIdEnding(post_json_object['object']) alsoUpdatePostId = remove_id_ending(post_json_object['object'])
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
@ -611,7 +611,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
# if the post is in the recent posts cache then mark it as muted # if the post is in the recent posts cache then mark it as muted
if recent_posts_cache.get('index'): if recent_posts_cache.get('index'):
post_id = \ post_id = \
removeIdEnding(post_json_object['id']).replace('/', '#') remove_id_ending(post_json_object['id']).replace('/', '#')
if post_id in recent_posts_cache['index']: if post_id in recent_posts_cache['index']:
print('MUTE: ' + post_id + ' is in recent posts cache') print('MUTE: ' + post_id + ' is in recent posts cache')
if recent_posts_cache.get('json'): if recent_posts_cache.get('json'):
@ -681,7 +681,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj = post_json_object['object'] postJsonObj = post_json_object['object']
else: else:
if has_object_string(post_json_object, debug): if has_object_string(post_json_object, debug):
alsoUpdatePostId = removeIdEnding(post_json_object['object']) alsoUpdatePostId = remove_id_ending(post_json_object['object'])
if postJsonObj.get('conversation'): if postJsonObj.get('conversation'):
unmuteConversation(base_dir, nickname, domain, unmuteConversation(base_dir, nickname, domain,
@ -727,7 +727,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
# if the post is in the recent posts cache then mark it as unmuted # if the post is in the recent posts cache then mark it as unmuted
if recent_posts_cache.get('index'): if recent_posts_cache.get('index'):
post_id = \ post_id = \
removeIdEnding(post_json_object['id']).replace('/', '#') remove_id_ending(post_json_object['id']).replace('/', '#')
if post_id in recent_posts_cache['index']: if post_id in recent_posts_cache['index']:
print('UNMUTE: ' + post_id + ' is in recent posts cache') print('UNMUTE: ' + post_id + ' is in recent posts cache')
if recent_posts_cache.get('json'): if recent_posts_cache.get('json'):
@ -790,7 +790,7 @@ def outboxMute(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s mute request arrived in outbox') print('DEBUG: c2s mute request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
if debug: if debug:
print('DEBUG: c2s mute object is not a status') print('DEBUG: c2s mute object is not a status')
@ -845,7 +845,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s undo mute request arrived in outbox') print('DEBUG: c2s undo mute request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = remove_id_ending(message_json['object']['object'])
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
if debug: if debug:
print('DEBUG: c2s undo mute object is not a status') print('DEBUG: c2s undo mute object is not a status')

View File

@ -14,7 +14,7 @@ from auth import createBasicAuthHeader
from utils import remove_domain_port from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import remove_post_from_cache from utils import remove_post_from_cache
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -593,7 +593,7 @@ def outboxBookmark(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s bookmark Add request arrived in outbox') print('DEBUG: c2s bookmark Add request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = remove_id_ending(message_json['object']['url'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageUrl) post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename: if not post_filename:
@ -649,7 +649,7 @@ def outboxUndoBookmark(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s unbookmark Remove request arrived in outbox') print('DEBUG: c2s unbookmark Remove request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = remove_id_ending(message_json['object']['url'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageUrl) post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename: if not post_filename:

View File

@ -10,7 +10,7 @@ __module_group__ = "Timeline"
import os import os
from utils import has_object_dict from utils import has_object_dict
from utils import acct_dir from utils import acct_dir
from utils import removeIdEnding from utils import remove_id_ending
def _getConversationFilename(base_dir: str, nickname: str, domain: str, def _getConversationFilename(base_dir: str, nickname: str, domain: str,
@ -39,7 +39,7 @@ def updateConversation(base_dir: str, nickname: str, domain: str,
_getConversationFilename(base_dir, nickname, domain, post_json_object) _getConversationFilename(base_dir, nickname, domain, post_json_object)
if not conversationFilename: if not conversationFilename:
return False return False
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
if not os.path.isfile(conversationFilename): if not os.path.isfile(conversationFilename):
try: try:
with open(conversationFilename, 'w+') as fp: with open(conversationFilename, 'w+') as fp:

View File

@ -285,7 +285,7 @@ from utils import containsInvalidChars
from utils import isSystemAccount from utils import isSystemAccount
from utils import setConfigParam from utils import setConfigParam
from utils import get_config_param from utils import get_config_param
from utils import removeIdEnding from utils import remove_id_ending
from utils import undoLikesCollectionEntry from utils import undoLikesCollectionEntry
from utils import deletePost from utils import deletePost
from utils import isBlogPost from utils import isBlogPost
@ -4659,7 +4659,7 @@ class PubServer(BaseHTTPRequestHandler):
print('ERROR: saving newswire state, ' + str(ex)) print('ERROR: saving newswire state, ' + str(ex))
# remove any previous cached news posts # remove any previous cached news posts
newsId = removeIdEnding(post_json_object['object']['id']) newsId = remove_id_ending(post_json_object['object']['id'])
newsId = newsId.replace('/', '#') newsId = newsId.replace('/', '#')
clearFromPostCaches(base_dir, clearFromPostCaches(base_dir,
self.server.recent_posts_cache, self.server.recent_posts_cache,
@ -7715,7 +7715,7 @@ class PubServer(BaseHTTPRequestHandler):
# save the announce straight to the outbox # save the announce straight to the outbox
# This is because the subsequent send is within a separate thread # This is because the subsequent send is within a separate thread
# but the html still needs to be generated before this call ends # but the html still needs to be generated before this call ends
announceId = removeIdEnding(announceJson['id']) announceId = remove_id_ending(announceJson['id'])
announceFilename = \ announceFilename = \
savePostToBox(base_dir, http_prefix, announceId, savePostToBox(base_dir, http_prefix, announceId,
self.postToNickname, domain_full, self.postToNickname, domain_full,
@ -13971,7 +13971,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.system_language) self.server.system_language)
message_json = {} message_json = {}
if pinnedPostJson: if pinnedPostJson:
post_id = removeIdEnding(pinnedPostJson['id']) post_id = remove_id_ending(pinnedPostJson['id'])
message_json = \ message_json = \
outboxMessageCreateWrap(self.server.http_prefix, outboxMessageCreateWrap(self.server.http_prefix,
nickname, nickname,
@ -18241,7 +18241,7 @@ class PubServer(BaseHTTPRequestHandler):
if self._postToOutbox(message_json, if self._postToOutbox(message_json,
self.server.project_version, None): self.server.project_version, None):
if message_json.get('id'): if message_json.get('id'):
locnStr = removeIdEnding(message_json['id']) locnStr = remove_id_ending(message_json['id'])
self.headers['Location'] = locnStr self.headers['Location'] = locnStr
self.send_response(201) self.send_response(201)
self.end_headers() self.end_headers()

View File

@ -13,7 +13,7 @@ from utils import has_object_string
from utils import remove_domain_port from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import locate_post from utils import locate_post
@ -138,7 +138,7 @@ def outboxDelete(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: delete not permitted from other instances') print('DEBUG: delete not permitted from other instances')
return return
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
if debug: if debug:
print('DEBUG: c2s delete object is not a status') print('DEBUG: c2s delete object is not a status')

View File

@ -39,7 +39,7 @@ from utils import get_config_param
from utils import has_users_path from utils import has_users_path
from utils import valid_post_date from utils import valid_post_date
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import isBlogPost from utils import isBlogPost
from utils import removeAvatarFromCache from utils import removeAvatarFromCache
@ -137,10 +137,10 @@ def _storeLastPostId(base_dir: str, nickname: str, domain: str,
if post_json_object['object'].get('attributedTo'): if post_json_object['object'].get('attributedTo'):
if isinstance(post_json_object['object']['attributedTo'], str): if isinstance(post_json_object['object']['attributedTo'], str):
actor = post_json_object['object']['attributedTo'] actor = post_json_object['object']['attributedTo']
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
if not actor: if not actor:
actor = post_json_object['actor'] actor = post_json_object['actor']
post_id = removeIdEnding(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
if not actor: if not actor:
return return
lastpostDir = acct_dir(base_dir, nickname, domain) + '/lastpost' lastpostDir = acct_dir(base_dir, nickname, domain) + '/lastpost'
@ -238,7 +238,7 @@ def storeHashTags(base_dir: str, nickname: str, domain: str,
if not validHashTag(tagName): if not validHashTag(tagName):
continue continue
tagsFilename = tagsDir + '/' + tagName + '.txt' tagsFilename = tagsDir + '/' + tagName + '.txt'
postUrl = removeIdEnding(post_json_object['id']) postUrl = remove_id_ending(post_json_object['id'])
postUrl = postUrl.replace('/', '#') postUrl = postUrl.replace('/', '#')
daysDiff = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1) daysDiff = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
daysSinceEpoch = daysDiff.days daysSinceEpoch = daysDiff.days
@ -531,13 +531,13 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
if post_json_object.get('id'): if post_json_object.get('id'):
if not isinstance(post_json_object['id'], str): if not isinstance(post_json_object['id'], str):
return None return None
originalPostId = removeIdEnding(post_json_object['id']) originalPostId = remove_id_ending(post_json_object['id'])
curr_time = datetime.datetime.utcnow() curr_time = datetime.datetime.utcnow()
post_id = None post_id = None
if post_json_object.get('id'): if post_json_object.get('id'):
post_id = removeIdEnding(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ") published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ")
if not post_id: if not post_id:
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -909,7 +909,7 @@ def _receiveUpdateToQuestion(recent_posts_cache: {}, message_json: {},
return return
if not has_actor(message_json, False): if not has_actor(message_json, False):
return return
messageId = removeIdEnding(message_json['id']) messageId = remove_id_ending(message_json['id'])
if '#' in messageId: if '#' in messageId:
messageId = messageId.split('#', 1)[0] messageId = messageId.split('#', 1)[0]
# find the question post # find the question post
@ -1566,7 +1566,7 @@ def _receiveBookmark(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s inbox bookmark Add request arrived in outbox') print('DEBUG: c2s inbox bookmark Add request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = remove_id_ending(message_json['object']['url'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageUrl) post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename: if not post_filename:
@ -1679,7 +1679,7 @@ def _receiveUndoBookmark(recent_posts_cache: {},
print('DEBUG: c2s inbox Remove bookmark ' + print('DEBUG: c2s inbox Remove bookmark ' +
'request arrived in outbox') 'request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = remove_id_ending(message_json['object']['url'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageUrl) post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename: if not post_filename:
@ -1773,7 +1773,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
if not os.path.isdir(base_dir + '/accounts/' + handle): if not os.path.isdir(base_dir + '/accounts/' + handle):
print('DEBUG: unknown recipient of like - ' + handle) print('DEBUG: unknown recipient of like - ' + handle)
# if this post in the outbox of the person? # if this post in the outbox of the person?
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
removeModerationPostFromIndex(base_dir, messageId, debug) removeModerationPostFromIndex(base_dir, messageId, debug)
handleNickname = handle.split('@')[0] handleNickname = handle.split('@')[0]
handleDomain = handle.split('@')[1] handleDomain = handle.split('@')[1]
@ -2164,7 +2164,7 @@ def populateReplies(base_dir: str, http_prefix: str, domain: str,
return False return False
# populate a text file containing the ids of replies # populate a text file containing the ids of replies
postRepliesFilename = post_filename.replace('.json', '.replies') postRepliesFilename = post_filename.replace('.json', '.replies')
messageId = removeIdEnding(message_json['id']) messageId = remove_id_ending(message_json['id'])
if os.path.isfile(postRepliesFilename): if os.path.isfile(postRepliesFilename):
numLines = sum(1 for line in open(postRepliesFilename)) numLines = sum(1 for line in open(postRepliesFilename))
if numLines > max_replies: if numLines > max_replies:
@ -2665,7 +2665,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
savePostToBox(base_dir, http_prefix, None, savePostToBox(base_dir, http_prefix, None,
nickname, domain, post_json_object, 'outbox') nickname, domain, post_json_object, 'outbox')
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
if debug: if debug:
print('Group announce: ' + post_id) print('Group announce: ' + post_id)
announceJson = \ announceJson = \
@ -2713,7 +2713,7 @@ def _inboxUpdateCalendar(base_dir: str, handle: str,
actorNickname, actorDomain): actorNickname, actorDomain):
return return
post_id = removeIdEnding(post_json_object['id']).replace('/', '#') post_id = remove_id_ending(post_json_object['id']).replace('/', '#')
# look for events within the tags list # look for events within the tags list
for tagDict in post_json_object['object']['tag']: for tagDict in post_json_object['object']['tag']:
@ -2848,7 +2848,7 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
mediaType = None mediaType = None
imageDescription = '' imageDescription = ''
city = 'London, England' city = 'London, England'
inReplyTo = removeIdEnding(senderPostId) inReplyTo = remove_id_ending(senderPostId)
inReplyToAtomUri = None inReplyToAtomUri = None
schedulePost = False schedulePost = False
eventDate = None eventDate = None
@ -2959,7 +2959,8 @@ def _isValidDM(base_dir: str, nickname: str, domain: str, port: int,
obj = post_json_object['object'] obj = post_json_object['object']
if isinstance(obj, dict): if isinstance(obj, dict):
if not obj.get('inReplyTo'): if not obj.get('inReplyTo'):
bouncedId = removeIdEnding(post_json_object['id']) bouncedId = \
remove_id_ending(post_json_object['id'])
_bounceDM(bouncedId, _bounceDM(bouncedId,
session, http_prefix, session, http_prefix,
base_dir, base_dir,
@ -3148,7 +3149,7 @@ def _lowFrequencyPostNotification(base_dir: str, http_prefix: str,
fromDomainFull = get_full_domain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
if notifyWhenPersonPosts(base_dir, nickname, domain, if notifyWhenPersonPosts(base_dir, nickname, domain,
fromNickname, fromDomainFull): fromNickname, fromDomainFull):
post_id = removeIdEnding(jsonObj['id']) post_id = remove_id_ending(jsonObj['id'])
domFull = get_full_domain(domain, port) domFull = get_full_domain(domain, port)
postLink = \ postLink = \
local_actor_url(http_prefix, nickname, domFull) + \ local_actor_url(http_prefix, nickname, domFull) + \

View File

@ -16,7 +16,7 @@ from utils import remove_domain_port
from utils import has_object_dict from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -358,7 +358,7 @@ def outboxLike(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s like request arrived in outbox') print('DEBUG: c2s like request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageId) post_filename = locate_post(base_dir, nickname, domain, messageId)
if not post_filename: if not post_filename:
@ -395,7 +395,7 @@ def outboxUndoLike(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s undo like request arrived in outbox') print('DEBUG: c2s undo like request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = remove_id_ending(message_json['object']['object'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageId) post_filename = locate_post(base_dir, nickname, domain, messageId)
if not post_filename: if not post_filename:

View File

@ -21,7 +21,7 @@ from utils import get_base_content_from_post
from utils import has_object_dict from utils import has_object_dict
from utils import getLocalNetworkAddresses from utils import getLocalNetworkAddresses
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import is_featured_writer from utils import is_featured_writer
@ -351,7 +351,7 @@ def postMessageToOutbox(session, translate: {},
' is not a permitted activity type') ' is not a permitted activity type')
return False return False
if message_json.get('id'): if message_json.get('id'):
post_id = removeIdEnding(message_json['id']) post_id = remove_id_ending(message_json['id'])
if debug: if debug:
print('DEBUG: id attribute exists within POST to outbox') print('DEBUG: id attribute exists within POST to outbox')
else: else:

View File

@ -35,7 +35,7 @@ from languages import understoodPostLanguage
from utils import get_user_paths from utils import get_user_paths
from utils import invalid_ciphertext from utils import invalid_ciphertext
from utils import has_object_stringType from utils import has_object_stringType
from utils import removeIdEnding from utils import remove_id_ending
from utils import replace_users_with_at from utils import replace_users_with_at
from utils import has_group_type from utils import has_group_type
from utils import get_base_content_from_post from utils import get_base_content_from_post
@ -2093,7 +2093,7 @@ def createDirectMessagePost(base_dir: str,
message_json['cc'] = [] message_json['cc'] = []
message_json['object']['cc'] = [] message_json['object']['cc'] = []
if schedulePost: if schedulePost:
post_id = removeIdEnding(message_json['object']['id']) post_id = remove_id_ending(message_json['object']['id'])
savePostToBox(base_dir, http_prefix, post_id, savePostToBox(base_dir, http_prefix, post_id,
nickname, domain, message_json, 'scheduled') nickname, domain, message_json, 'scheduled')
return message_json return message_json
@ -4539,7 +4539,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
post_id = None post_id = None
if post_json_object.get('id'): if post_json_object.get('id'):
post_id = removeIdEnding(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
announceFilename = \ announceFilename = \
announceCacheDir + '/' + \ announceCacheDir + '/' + \
post_json_object['object'].replace('/', '#') + '.json' post_json_object['object'].replace('/', '#') + '.json'
@ -5213,7 +5213,7 @@ def editedPostFilename(base_dir: str, nickname: str, domain: str,
actor.replace('/', '#') actor.replace('/', '#')
if not os.path.isfile(actorFilename): if not os.path.isfile(actorFilename):
return '' return ''
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
lastpost_id = None lastpost_id = None
try: try:
with open(actorFilename, 'r') as fp: with open(actorFilename, 'r') as fp:

View File

@ -18,7 +18,7 @@ from utils import remove_domain_port
from utils import has_object_dict from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import remove_id_ending
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -381,7 +381,7 @@ def outboxReaction(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s reaction request arrived in outbox') print('DEBUG: c2s reaction request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = remove_id_ending(message_json['object'])
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
emojiContent = message_json['content'] emojiContent = message_json['content']
post_filename = locate_post(base_dir, nickname, domain, messageId) post_filename = locate_post(base_dir, nickname, domain, messageId)
@ -423,7 +423,7 @@ def outboxUndoReaction(recent_posts_cache: {},
if debug: if debug:
print('DEBUG: c2s undo reaction request arrived in outbox') print('DEBUG: c2s undo reaction request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = remove_id_ending(message_json['object']['object'])
emojiContent = message_json['object']['content'] emojiContent = message_json['object']['content']
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageId) post_filename = locate_post(base_dir, nickname, domain, messageId)
@ -551,7 +551,7 @@ def htmlEmojiReactions(post_json_object: {}, interactive: bool,
reactions[emojiContent]['handles'].append(emojiHandle) reactions[emojiContent]['handles'].append(emojiHandle)
if len(reactions.items()) == 0: if len(reactions.items()) == 0:
return '' return ''
reactBy = removeIdEnding(post_json_object['object']['id']) reactBy = remove_id_ending(post_json_object['object']['id'])
htmlStr = '<div class="emojiReactionBar">\n' htmlStr = '<div class="emojiReactionBar">\n'
for emojiContent, item in reactions.items(): for emojiContent, item in reactions.items():
count = item['count'] count = item['count']

View File

@ -11,7 +11,7 @@ import os
import html import html
import random import random
import urllib.parse import urllib.parse
from utils import removeIdEnding from utils import remove_id_ending
from utils import is_dm from utils import is_dm
from utils import is_reply from utils import is_reply
from utils import camel_case_split from utils import camel_case_split
@ -491,7 +491,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
announcedHandle + '. ' + content announcedHandle + '. ' + content
post_id = None post_id = None
if post_json_object['object'].get('id'): if post_json_object['object'].get('id'):
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
followRequestsExist = False followRequestsExist = False
followRequestsList = [] followRequestsList = []

View File

@ -72,7 +72,7 @@ from utils import decoded_host
from utils import get_full_domain from utils import get_full_domain
from utils import validNickname from utils import validNickname
from utils import firstParagraphFromString from utils import firstParagraphFromString
from utils import removeIdEnding from utils import remove_id_ending
from utils import updateRecentPostsCache from utils import updateRecentPostsCache
from utils import followPerson from utils import followPerson
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -2946,7 +2946,7 @@ def testClientToServer(base_dir: str):
outboxPostFilename = outboxPath + '/' + name outboxPostFilename = outboxPath + '/' + name
post_json_object = load_json(outboxPostFilename, 0) post_json_object = load_json(outboxPostFilename, 0)
if post_json_object: if post_json_object:
outboxPostId = removeIdEnding(post_json_object['id']) outboxPostId = remove_id_ending(post_json_object['id'])
assert outboxPostId assert outboxPostId
print('message id obtained: ' + outboxPostId) print('message id obtained: ' + outboxPostId)
assert validInbox(bobDir, 'bob', bobDomain) assert validInbox(bobDir, 'bob', bobDomain)
@ -3836,25 +3836,25 @@ def _testJsonPostAllowsComments():
def _testRemoveIdEnding(): def _testRemoveIdEnding():
print('testRemoveIdEnding') print('testRemoveIdEnding')
testStr = 'https://activitypub.somedomain.net' testStr = 'https://activitypub.somedomain.net'
resultStr = removeIdEnding(testStr) resultStr = remove_id_ending(testStr)
assert resultStr == 'https://activitypub.somedomain.net' assert resultStr == 'https://activitypub.somedomain.net'
testStr = \ testStr = \
'https://activitypub.somedomain.net/users/foo/' + \ 'https://activitypub.somedomain.net/users/foo/' + \
'statuses/34544814814/activity' 'statuses/34544814814/activity'
resultStr = removeIdEnding(testStr) resultStr = remove_id_ending(testStr)
assert resultStr == \ assert resultStr == \
'https://activitypub.somedomain.net/users/foo/statuses/34544814814' 'https://activitypub.somedomain.net/users/foo/statuses/34544814814'
testStr = \ testStr = \
'https://undo.somedomain.net/users/foo/statuses/34544814814/undo' 'https://undo.somedomain.net/users/foo/statuses/34544814814/undo'
resultStr = removeIdEnding(testStr) resultStr = remove_id_ending(testStr)
assert resultStr == \ assert resultStr == \
'https://undo.somedomain.net/users/foo/statuses/34544814814' 'https://undo.somedomain.net/users/foo/statuses/34544814814'
testStr = \ testStr = \
'https://event.somedomain.net/users/foo/statuses/34544814814/event' 'https://event.somedomain.net/users/foo/statuses/34544814814/event'
resultStr = removeIdEnding(testStr) resultStr = remove_id_ending(testStr)
assert resultStr == \ assert resultStr == \
'https://event.somedomain.net/users/foo/statuses/34544814814' 'https://event.somedomain.net/users/foo/statuses/34544814814'

View File

@ -598,7 +598,7 @@ def getFollowersOfPerson(base_dir: str,
return followers return followers
def removeIdEnding(idStr: str) -> str: def remove_id_ending(idStr: str) -> str:
"""Removes endings such as /activity and /undo """Removes endings such as /activity and /undo
""" """
if idStr.endswith('/activity'): if idStr.endswith('/activity'):
@ -1248,7 +1248,7 @@ def locateNewsVotes(base_dir: str, domain: str,
postUrl.strip().replace('\n', '').replace('\r', '') postUrl.strip().replace('\n', '').replace('\r', '')
# if this post in the shared inbox? # if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#') postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
if postUrl.endswith('.json'): if postUrl.endswith('.json'):
postUrl = postUrl + '.votes' postUrl = postUrl + '.votes'
@ -1272,7 +1272,7 @@ def locateNewsArrival(base_dir: str, domain: str,
postUrl.strip().replace('\n', '').replace('\r', '') postUrl.strip().replace('\n', '').replace('\r', '')
# if this post in the shared inbox? # if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#') postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
if postUrl.endswith('.json'): if postUrl.endswith('.json'):
postUrl = postUrl + '.arrived' postUrl = postUrl + '.arrived'
@ -1336,7 +1336,7 @@ def locate_post(base_dir: str, nickname: str, domain: str,
extension = 'replies' extension = 'replies'
# if this post in the shared inbox? # if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#') postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
# add the extension # add the extension
postUrl = postUrl + '.' + extension postUrl = postUrl + '.' + extension
@ -1492,7 +1492,7 @@ def removeModerationPostFromIndex(base_dir: str, postUrl: str,
moderation_index_file = base_dir + '/accounts/moderation.txt' moderation_index_file = base_dir + '/accounts/moderation.txt'
if not os.path.isfile(moderation_index_file): if not os.path.isfile(moderation_index_file):
return return
post_id = removeIdEnding(postUrl) post_id = remove_id_ending(postUrl)
if post_id in open(moderation_index_file).read(): if post_id in open(moderation_index_file).read():
with open(moderation_index_file, 'r') as f: with open(moderation_index_file, 'r') as f:
lines = f.readlines() lines = f.readlines()
@ -1520,7 +1520,7 @@ def _is_reply_to_blog_post(base_dir: str, nickname: str, domain: str,
acct_dir(base_dir, nickname, domain) + '/tlblogs.index' acct_dir(base_dir, nickname, domain) + '/tlblogs.index'
if not os.path.isfile(blogs_index_filename): if not os.path.isfile(blogs_index_filename):
return False return False
post_id = removeIdEnding(post_json_object['object']['inReplyTo']) post_id = remove_id_ending(post_json_object['object']['inReplyTo'])
post_id = post_id.replace('/', '#') post_id = post_id.replace('/', '#')
if post_id in open(blogs_index_filename).read(): if post_id in open(blogs_index_filename).read():
return True return True
@ -1583,7 +1583,7 @@ def remove_post_from_cache(post_json_object: {},
post_id = post_json_object['id'] post_id = post_json_object['id']
if '#' in post_id: if '#' in post_id:
post_id = post_id.split('#', 1)[0] post_id = post_id.split('#', 1)[0]
post_id = removeIdEnding(post_id).replace('/', '#') post_id = remove_id_ending(post_id).replace('/', '#')
if post_id not in recent_posts_cache['index']: if post_id not in recent_posts_cache['index']:
return return
@ -1633,7 +1633,7 @@ def _deleteHashtagsOnPost(base_dir: str, post_json_object: {}) -> None:
return return
# get the id of the post # get the id of the post
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
for tag in post_json_object['object']['tag']: for tag in post_json_object['object']['tag']:
if not tag.get('type'): if not tag.get('type'):
continue continue
@ -1772,7 +1772,7 @@ def deletePost(base_dir: str, http_prefix: str,
if has_object_dict(post_json_object): if has_object_dict(post_json_object):
if post_json_object['object'].get('moderationStatus'): if post_json_object['object'].get('moderationStatus'):
if post_json_object.get('id'): if post_json_object.get('id'):
post_id = removeIdEnding(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
removeModerationPostFromIndex(base_dir, post_id, debug) removeModerationPostFromIndex(base_dir, post_id, debug)
# remove any hashtags index entries # remove any hashtags index entries
@ -2004,7 +2004,7 @@ def get_cached_post_filename(base_dir: str, nickname: str, domain: str,
if '@' not in cachedPostDir: if '@' not in cachedPostDir:
# print('ERROR: invalid html cache directory ' + cachedPostDir) # print('ERROR: invalid html cache directory ' + cachedPostDir)
return None return None
cachedPostId = removeIdEnding(post_json_object['id']) cachedPostId = remove_id_ending(post_json_object['id'])
cached_post_filename = cachedPostDir + '/' + cachedPostId.replace('/', '#') cached_post_filename = cachedPostDir + '/' + cachedPostId.replace('/', '#')
return cached_post_filename + '.html' return cached_post_filename + '.html'
@ -2018,7 +2018,7 @@ def updateRecentPostsCache(recent_posts_cache: {}, max_recent_posts: int,
post_id = post_json_object['id'] post_id = post_json_object['id']
if '#' in post_id: if '#' in post_id:
post_id = post_id.split('#', 1)[0] post_id = post_id.split('#', 1)[0]
post_id = removeIdEnding(post_id).replace('/', '#') post_id = remove_id_ending(post_id).replace('/', '#')
if recent_posts_cache.get('index'): if recent_posts_cache.get('index'):
if post_id in recent_posts_cache['index']: if post_id in recent_posts_cache['index']:
return return
@ -2442,7 +2442,7 @@ def update_announce_collection(recent_posts_cache: {},
pprint(post_json_object) pprint(post_json_object)
print('DEBUG: post ' + post_filename + ' has no object') print('DEBUG: post ' + post_filename + ' has no object')
return return
postUrl = removeIdEnding(post_json_object['id']) + '/shares' postUrl = remove_id_ending(post_json_object['id']) + '/shares'
if not post_json_object['object'].get('shares'): if not post_json_object['object'].get('shares'):
if debug: if debug:
print('DEBUG: Adding initial shares (announcements) to ' + print('DEBUG: Adding initial shares (announcements) to ' +

View File

@ -10,7 +10,7 @@ __module_group__ = "Timeline"
from utils import get_full_domain from utils import get_full_domain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import removeIdEnding from utils import remove_id_ending
from blocking import isBlocked from blocking import isBlocked
from filters import isFiltered from filters import isFiltered
@ -89,7 +89,7 @@ def convertVideoToNote(base_dir: str, nickname: str, domain: str,
content += '<p>' + post_json_object['license']['name'] + '</p>' content += '<p>' + post_json_object['license']['name'] + '</p>'
content += post_json_object['content'] content += post_json_object['content']
conversationId = removeIdEnding(post_json_object['id']) conversationId = remove_id_ending(post_json_object['id'])
mediaType = None mediaType = None
mediaUrl = None mediaUrl = None
@ -131,7 +131,7 @@ def convertVideoToNote(base_dir: str, nickname: str, domain: str,
content += '<a href="' + mediaMagnet + '">🧲</a>' content += '<a href="' + mediaMagnet + '">🧲</a>'
content += '</p>' content += '</p>'
newPostId = removeIdEnding(post_json_object['id']) newPostId = remove_id_ending(post_json_object['id'])
newPost = { newPost = {
'@context': post_json_object['@context'], '@context': post_json_object['@context'],
'id': newPostId + '/activity', 'id': newPostId + '/activity',

View File

@ -47,7 +47,7 @@ from utils import isBlogPost
from utils import getDisplayName from utils import getDisplayName
from utils import isPublicPost from utils import isPublicPost
from utils import updateRecentPostsCache from utils import updateRecentPostsCache
from utils import removeIdEnding from utils import remove_id_ending
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import acct_dir from utils import acct_dir
@ -392,7 +392,7 @@ def _getReplyIconHtml(base_dir: str, nickname: str, domain: str,
# reply is permitted - create reply icon # reply is permitted - create reply icon
replyToLink = removeHashFromPostId(post_json_object['object']['id']) replyToLink = removeHashFromPostId(post_json_object['object']['id'])
replyToLink = removeIdEnding(replyToLink) replyToLink = remove_id_ending(replyToLink)
# see Mike MacGirvin's replyTo suggestion # see Mike MacGirvin's replyTo suggestion
if post_json_object['object'].get('replyTo'): if post_json_object['object'].get('replyTo'):
@ -475,7 +475,7 @@ def _getEditIconHtml(base_dir: str, nickname: str, domain_full: str,
(is_editor(base_dir, nickname) and (is_editor(base_dir, nickname) and
actor.endswith('/' + domain_full + '/users/news'))): actor.endswith('/' + domain_full + '/users/news'))):
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
if '/statuses/' not in post_id: if '/statuses/' not in post_id:
return editStr return editStr
@ -571,10 +571,10 @@ def _getAnnounceIconHtml(isAnnounced: bool,
announceTitle = undoTheRepeatStr announceTitle = undoTheRepeatStr
if announceJsonObject: if announceJsonObject:
unannounceLinkStr = '?unannounce=' + \ unannounceLinkStr = '?unannounce=' + \
removeIdEnding(announceJsonObject['id']) remove_id_ending(announceJsonObject['id'])
announcePostId = removeHashFromPostId(post_json_object['object']['id']) announcePostId = removeHashFromPostId(post_json_object['object']['id'])
announcePostId = removeIdEnding(announcePostId) announcePostId = remove_id_ending(announcePostId)
announceLinkStr = '?' + \ announceLinkStr = '?' + \
announceLink + '=' + announcePostId + pageNumberParam announceLink + '=' + announcePostId + pageNumberParam
announceStr = \ announceStr = \
@ -643,7 +643,7 @@ def _getLikeIconHtml(nickname: str, domain_full: str,
likeStr += likeCountStr.replace('(', '').replace(')', '').strip() likeStr += likeCountStr.replace('(', '').replace(')', '').strip()
likeStr += '</label>\n' likeStr += '</label>\n'
likePostId = removeHashFromPostId(post_json_object['id']) likePostId = removeHashFromPostId(post_json_object['id'])
likePostId = removeIdEnding(likePostId) likePostId = remove_id_ending(likePostId)
likeStr += \ likeStr += \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \ ' <a class="imageAnchor" href="/users/' + nickname + '?' + \
likeLink + '=' + likePostId + \ likeLink + '=' + likePostId + \
@ -690,7 +690,7 @@ def _getBookmarkIconHtml(nickname: str, domain_full: str,
bookmarkTitle = translate[bookmarkTitle] bookmarkTitle = translate[bookmarkTitle]
_logPostTiming(enableTimingLog, postStartTime, '12.6') _logPostTiming(enableTimingLog, postStartTime, '12.6')
bookmarkPostId = removeHashFromPostId(post_json_object['object']['id']) bookmarkPostId = removeHashFromPostId(post_json_object['object']['id'])
bookmarkPostId = removeIdEnding(bookmarkPostId) bookmarkPostId = remove_id_ending(bookmarkPostId)
bookmarkStr = \ bookmarkStr = \
' <a class="imageAnchor" href="/users/' + nickname + '?' + \ ' <a class="imageAnchor" href="/users/' + nickname + '?' + \
bookmarkLink + '=' + bookmarkPostId + \ bookmarkLink + '=' + bookmarkPostId + \
@ -728,7 +728,7 @@ def _getReactionIconHtml(nickname: str, domain_full: str,
reactionTitle = translate[reactionTitle] reactionTitle = translate[reactionTitle]
_logPostTiming(enableTimingLog, postStartTime, '12.65') _logPostTiming(enableTimingLog, postStartTime, '12.65')
reactionPostId = removeHashFromPostId(post_json_object['object']['id']) reactionPostId = removeHashFromPostId(post_json_object['object']['id'])
reactionPostId = removeIdEnding(reactionPostId) reactionPostId = remove_id_ending(reactionPostId)
reactionStr = \ reactionStr = \
' <a class="imageAnchor" href="/users/' + nickname + \ ' <a class="imageAnchor" href="/users/' + nickname + \
'?selreact=' + reactionPostId + pageNumberParam + \ '?selreact=' + reactionPostId + pageNumberParam + \
@ -916,7 +916,7 @@ def _announceUnattributedHtml(translate: {},
announcesStr = 'announces' announcesStr = 'announces'
if translate.get(announcesStr): if translate.get(announcesStr):
announcesStr = translate[announcesStr] announcesStr = translate[announcesStr]
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
return ' <img loading="lazy" title="' + \ return ' <img loading="lazy" title="' + \
announcesStr + '" alt="' + \ announcesStr + '" alt="' + \
announcesStr + '" src="/icons' + \ announcesStr + '" src="/icons' + \
@ -934,7 +934,7 @@ def _announceWithDisplayNameHtml(translate: {},
announcesStr = 'announces' announcesStr = 'announces'
if translate.get(announcesStr): if translate.get(announcesStr):
announcesStr = translate[announcesStr] announcesStr = translate[announcesStr]
post_id = removeIdEnding(post_json_object['object']['id']) post_id = remove_id_ending(post_json_object['object']['id'])
return ' <img loading="lazy" title="' + \ return ' <img loading="lazy" title="' + \
announcesStr + '" alt="' + \ announcesStr + '" alt="' + \
announcesStr + '" src="/' + \ announcesStr + '" src="/' + \
@ -1373,7 +1373,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
messageId = '' messageId = ''
if post_json_object.get('id'): if post_json_object.get('id'):
messageId = removeHashFromPostId(post_json_object['id']) messageId = removeHashFromPostId(post_json_object['id'])
messageId = removeIdEnding(messageId) messageId = remove_id_ending(messageId)
_logPostTiming(enableTimingLog, postStartTime, '2') _logPostTiming(enableTimingLog, postStartTime, '2')
@ -1473,7 +1473,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
avatarImageInPost = \ avatarImageInPost = \
' <div class="timeline-avatar">' + avatarLink + '</div>\n' ' <div class="timeline-avatar">' + avatarLink + '</div>\n'
timelinePostBookmark = removeIdEnding(post_json_object['id']) timelinePostBookmark = remove_id_ending(post_json_object['id'])
timelinePostBookmark = timelinePostBookmark.replace('://', '-') timelinePostBookmark = timelinePostBookmark.replace('://', '-')
timelinePostBookmark = timelinePostBookmark.replace('/', '-') timelinePostBookmark = timelinePostBookmark.replace('/', '-')
@ -1509,7 +1509,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
blockedCache) blockedCache)
if not postJsonAnnounce: if not postJsonAnnounce:
# if the announce could not be downloaded then mark it as rejected # if the announce could not be downloaded then mark it as rejected
announcedPostId = removeIdEnding(post_json_object['id']) announcedPostId = remove_id_ending(post_json_object['id'])
reject_post_id(base_dir, nickname, domain, announcedPostId, reject_post_id(base_dir, nickname, domain, announcedPostId,
recent_posts_cache) recent_posts_cache)
return '' return ''
@ -2074,7 +2074,7 @@ def htmlIndividualPost(cssCache: {},
system_language, max_like_count, system_language, max_like_count,
False, authorized, False, False, False, False, False, authorized, False, False, False, False,
cw_lists, lists_enabled) cw_lists, lists_enabled)
messageId = removeIdEnding(post_json_object['id']) messageId = remove_id_ending(post_json_object['id'])
# show the previous posts # show the previous posts
if has_object_dict(post_json_object): if has_object_dict(post_json_object):
@ -2252,7 +2252,7 @@ def htmlEmojiReactionPicker(cssCache: {},
reactionsJson = load_json(reactionsFilename) reactionsJson = load_json(reactionsFilename)
emojiPicksStr = '' emojiPicksStr = ''
baseUrl = '/users/' + nickname baseUrl = '/users/' + nickname
post_id = removeIdEnding(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
for category, item in reactionsJson.items(): for category, item in reactionsJson.items():
emojiPicksStr += '<div class="container">\n' emojiPicksStr += '<div class="container">\n'
for emojiContent in item: for emojiContent in item:

View File

@ -9,7 +9,7 @@ __module_group__ = "Web Interface"
import os import os
from question import isQuestion from question import isQuestion
from utils import removeIdEnding from utils import remove_id_ending
from utils import acct_dir from utils import acct_dir
@ -23,7 +23,7 @@ def insertQuestion(base_dir: str, translate: {},
return content return content
if len(post_json_object['object']['oneOf']) == 0: if len(post_json_object['object']['oneOf']) == 0:
return content return content
messageId = removeIdEnding(post_json_object['id']) messageId = remove_id_ending(post_json_object['id'])
if '#' in messageId: if '#' in messageId:
messageId = messageId.split('#', 1)[0] messageId = messageId.split('#', 1)[0]
pageNumberStr = '' pageNumberStr = ''

View File

@ -15,7 +15,7 @@ from utils import dangerousMarkup
from utils import get_config_param from utils import get_config_param
from utils import get_full_domain from utils import get_full_domain
from utils import is_editor from utils import is_editor
from utils import removeIdEnding from utils import remove_id_ending
from utils import acct_dir from utils import acct_dir
from utils import is_float from utils import is_float
from utils import local_actor_url from utils import local_actor_url
@ -876,7 +876,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
# is the post in the memory cache of recent ones? # is the post in the memory cache of recent ones?
currTlStr = None currTlStr = None
if boxName != 'tlmedia' and recent_posts_cache.get('html'): if boxName != 'tlmedia' and recent_posts_cache.get('html'):
post_id = removeIdEnding(item['id']).replace('/', '#') post_id = remove_id_ending(item['id']).replace('/', '#')
if recent_posts_cache['html'].get(post_id): if recent_posts_cache['html'].get(post_id):
currTlStr = recent_posts_cache['html'][post_id] currTlStr = recent_posts_cache['html'][post_id]
currTlStr = \ currTlStr = \