Snake case

main
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_group_type
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 get_full_domain
from utils import getStatusNumber
@ -408,7 +408,7 @@ def outboxUndoAnnounce(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageId)
if not post_filename:

View File

@ -24,7 +24,7 @@ from utils import fileLastModified
from utils import setConfigParam
from utils import has_users_path
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import isEvil
from utils import locate_post
from utils import evilIncarnate
@ -432,7 +432,7 @@ def outboxBlock(base_dir: str, http_prefix: str,
if debug:
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 debug:
print('DEBUG: c2s block object is not a status')
@ -488,7 +488,7 @@ def outboxUndoBlock(base_dir: str, http_prefix: str,
if debug:
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 debug:
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']
else:
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)
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 recent_posts_cache.get('index'):
post_id = \
removeIdEnding(post_json_object['id']).replace('/', '#')
remove_id_ending(post_json_object['id']).replace('/', '#')
if post_id in recent_posts_cache['index']:
print('MUTE: ' + post_id + ' is in recent posts cache')
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']
else:
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'):
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 recent_posts_cache.get('index'):
post_id = \
removeIdEnding(post_json_object['id']).replace('/', '#')
remove_id_ending(post_json_object['id']).replace('/', '#')
if post_id in recent_posts_cache['index']:
print('UNMUTE: ' + post_id + ' is in recent posts cache')
if recent_posts_cache.get('json'):
@ -790,7 +790,7 @@ def outboxMute(base_dir: str, http_prefix: str,
if debug:
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 debug:
print('DEBUG: c2s mute object is not a status')
@ -845,7 +845,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
if debug:
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 debug:
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 has_users_path
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 urlPermitted
from utils import getNicknameFromActor
@ -593,7 +593,7 @@ def outboxBookmark(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename:
@ -649,7 +649,7 @@ def outboxUndoBookmark(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename:

View File

@ -10,7 +10,7 @@ __module_group__ = "Timeline"
import os
from utils import has_object_dict
from utils import acct_dir
from utils import removeIdEnding
from utils import remove_id_ending
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)
if not conversationFilename:
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):
try:
with open(conversationFilename, 'w+') as fp:

View File

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

View File

@ -13,7 +13,7 @@ from utils import has_object_string
from utils import remove_domain_port
from utils import has_users_path
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import locate_post
@ -138,7 +138,7 @@ def outboxDelete(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: delete not permitted from other instances')
return
messageId = removeIdEnding(message_json['object'])
messageId = remove_id_ending(message_json['object'])
if '/statuses/' not in messageId:
if debug:
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 valid_post_date
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import getProtocolPrefixes
from utils import isBlogPost
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 isinstance(post_json_object['object']['attributedTo'], str):
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:
actor = post_json_object['actor']
post_id = removeIdEnding(post_json_object['id'])
post_id = remove_id_ending(post_json_object['id'])
if not actor:
return
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):
continue
tagsFilename = tagsDir + '/' + tagName + '.txt'
postUrl = removeIdEnding(post_json_object['id'])
postUrl = remove_id_ending(post_json_object['id'])
postUrl = postUrl.replace('/', '#')
daysDiff = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
daysSinceEpoch = daysDiff.days
@ -531,13 +531,13 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
if post_json_object.get('id'):
if not isinstance(post_json_object['id'], str):
return None
originalPostId = removeIdEnding(post_json_object['id'])
originalPostId = remove_id_ending(post_json_object['id'])
curr_time = datetime.datetime.utcnow()
post_id = None
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")
if not post_id:
statusNumber, published = getStatusNumber()
@ -909,7 +909,7 @@ def _receiveUpdateToQuestion(recent_posts_cache: {}, message_json: {},
return
if not has_actor(message_json, False):
return
messageId = removeIdEnding(message_json['id'])
messageId = remove_id_ending(message_json['id'])
if '#' in messageId:
messageId = messageId.split('#', 1)[0]
# find the question post
@ -1566,7 +1566,7 @@ def _receiveBookmark(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageUrl)
if not post_filename:
@ -1679,7 +1679,7 @@ def _receiveUndoBookmark(recent_posts_cache: {},
print('DEBUG: c2s inbox Remove bookmark ' +
'request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url'])
messageUrl = remove_id_ending(message_json['object']['url'])
domain = remove_domain_port(domain)
post_filename = locate_post(base_dir, nickname, domain, messageUrl)
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):
print('DEBUG: unknown recipient of like - ' + handle)
# 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)
handleNickname = handle.split('@')[0]
handleDomain = handle.split('@')[1]
@ -2164,7 +2164,7 @@ def populateReplies(base_dir: str, http_prefix: str, domain: str,
return False
# populate a text file containing the ids of replies
postRepliesFilename = post_filename.replace('.json', '.replies')
messageId = removeIdEnding(message_json['id'])
messageId = remove_id_ending(message_json['id'])
if os.path.isfile(postRepliesFilename):
numLines = sum(1 for line in open(postRepliesFilename))
if numLines > max_replies:
@ -2665,7 +2665,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
savePostToBox(base_dir, http_prefix, None,
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:
print('Group announce: ' + post_id)
announceJson = \
@ -2713,7 +2713,7 @@ def _inboxUpdateCalendar(base_dir: str, handle: str,
actorNickname, actorDomain):
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
for tagDict in post_json_object['object']['tag']:
@ -2848,7 +2848,7 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
mediaType = None
imageDescription = ''
city = 'London, England'
inReplyTo = removeIdEnding(senderPostId)
inReplyTo = remove_id_ending(senderPostId)
inReplyToAtomUri = None
schedulePost = False
eventDate = None
@ -2959,7 +2959,8 @@ def _isValidDM(base_dir: str, nickname: str, domain: str, port: int,
obj = post_json_object['object']
if isinstance(obj, dict):
if not obj.get('inReplyTo'):
bouncedId = removeIdEnding(post_json_object['id'])
bouncedId = \
remove_id_ending(post_json_object['id'])
_bounceDM(bouncedId,
session, http_prefix,
base_dir,
@ -3148,7 +3149,7 @@ def _lowFrequencyPostNotification(base_dir: str, http_prefix: str,
fromDomainFull = get_full_domain(fromDomain, fromPort)
if notifyWhenPersonPosts(base_dir, nickname, domain,
fromNickname, fromDomainFull):
post_id = removeIdEnding(jsonObj['id'])
post_id = remove_id_ending(jsonObj['id'])
domFull = get_full_domain(domain, port)
postLink = \
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_users_path
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import urlPermitted
from utils import getNicknameFromActor
from utils import getDomainFromActor
@ -358,7 +358,7 @@ def outboxLike(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageId)
if not post_filename:
@ -395,7 +395,7 @@ def outboxUndoLike(recent_posts_cache: {},
if debug:
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)
post_filename = locate_post(base_dir, nickname, domain, messageId)
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 getLocalNetworkAddresses
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import getDomainFromActor
from utils import dangerousMarkup
from utils import is_featured_writer
@ -351,7 +351,7 @@ def postMessageToOutbox(session, translate: {},
' is not a permitted activity type')
return False
if message_json.get('id'):
post_id = removeIdEnding(message_json['id'])
post_id = remove_id_ending(message_json['id'])
if debug:
print('DEBUG: id attribute exists within POST to outbox')
else:

View File

@ -35,7 +35,7 @@ from languages import understoodPostLanguage
from utils import get_user_paths
from utils import invalid_ciphertext
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 has_group_type
from utils import get_base_content_from_post
@ -2093,7 +2093,7 @@ def createDirectMessagePost(base_dir: str,
message_json['cc'] = []
message_json['object']['cc'] = []
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,
nickname, domain, message_json, 'scheduled')
return message_json
@ -4539,7 +4539,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
post_id = None
if post_json_object.get('id'):
post_id = removeIdEnding(post_json_object['id'])
post_id = remove_id_ending(post_json_object['id'])
announceFilename = \
announceCacheDir + '/' + \
post_json_object['object'].replace('/', '#') + '.json'
@ -5213,7 +5213,7 @@ def editedPostFilename(base_dir: str, nickname: str, domain: str,
actor.replace('/', '#')
if not os.path.isfile(actorFilename):
return ''
post_id = removeIdEnding(post_json_object['object']['id'])
post_id = remove_id_ending(post_json_object['object']['id'])
lastpost_id = None
try:
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_users_path
from utils import get_full_domain
from utils import removeIdEnding
from utils import remove_id_ending
from utils import urlPermitted
from utils import getNicknameFromActor
from utils import getDomainFromActor
@ -381,7 +381,7 @@ def outboxReaction(recent_posts_cache: {},
if debug:
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)
emojiContent = message_json['content']
post_filename = locate_post(base_dir, nickname, domain, messageId)
@ -423,7 +423,7 @@ def outboxUndoReaction(recent_posts_cache: {},
if debug:
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']
domain = remove_domain_port(domain)
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)
if len(reactions.items()) == 0:
return ''
reactBy = removeIdEnding(post_json_object['object']['id'])
reactBy = remove_id_ending(post_json_object['object']['id'])
htmlStr = '<div class="emojiReactionBar">\n'
for emojiContent, item in reactions.items():
count = item['count']

View File

@ -11,7 +11,7 @@ import os
import html
import random
import urllib.parse
from utils import removeIdEnding
from utils import remove_id_ending
from utils import is_dm
from utils import is_reply
from utils import camel_case_split
@ -491,7 +491,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
announcedHandle + '. ' + content
post_id = None
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
followRequestsList = []

View File

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

View File

@ -598,7 +598,7 @@ def getFollowersOfPerson(base_dir: str,
return followers
def removeIdEnding(idStr: str) -> str:
def remove_id_ending(idStr: str) -> str:
"""Removes endings such as /activity and /undo
"""
if idStr.endswith('/activity'):
@ -1248,7 +1248,7 @@ def locateNewsVotes(base_dir: str, domain: str,
postUrl.strip().replace('\n', '').replace('\r', '')
# if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#')
postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
if postUrl.endswith('.json'):
postUrl = postUrl + '.votes'
@ -1272,7 +1272,7 @@ def locateNewsArrival(base_dir: str, domain: str,
postUrl.strip().replace('\n', '').replace('\r', '')
# if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#')
postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
if postUrl.endswith('.json'):
postUrl = postUrl + '.arrived'
@ -1336,7 +1336,7 @@ def locate_post(base_dir: str, nickname: str, domain: str,
extension = 'replies'
# if this post in the shared inbox?
postUrl = removeIdEnding(postUrl.strip()).replace('/', '#')
postUrl = remove_id_ending(postUrl.strip()).replace('/', '#')
# add the extension
postUrl = postUrl + '.' + extension
@ -1492,7 +1492,7 @@ def removeModerationPostFromIndex(base_dir: str, postUrl: str,
moderation_index_file = base_dir + '/accounts/moderation.txt'
if not os.path.isfile(moderation_index_file):
return
post_id = removeIdEnding(postUrl)
post_id = remove_id_ending(postUrl)
if post_id in open(moderation_index_file).read():
with open(moderation_index_file, 'r') as f:
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'
if not os.path.isfile(blogs_index_filename):
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('/', '#')
if post_id in open(blogs_index_filename).read():
return True
@ -1583,7 +1583,7 @@ def remove_post_from_cache(post_json_object: {},
post_id = post_json_object['id']
if '#' in post_id:
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']:
return
@ -1633,7 +1633,7 @@ def _deleteHashtagsOnPost(base_dir: str, post_json_object: {}) -> None:
return
# 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']:
if not tag.get('type'):
continue
@ -1772,7 +1772,7 @@ def deletePost(base_dir: str, http_prefix: str,
if has_object_dict(post_json_object):
if post_json_object['object'].get('moderationStatus'):
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)
# 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:
# print('ERROR: invalid html cache directory ' + cachedPostDir)
return None
cachedPostId = removeIdEnding(post_json_object['id'])
cachedPostId = remove_id_ending(post_json_object['id'])
cached_post_filename = cachedPostDir + '/' + cachedPostId.replace('/', '#')
return cached_post_filename + '.html'
@ -2018,7 +2018,7 @@ def updateRecentPostsCache(recent_posts_cache: {}, max_recent_posts: int,
post_id = post_json_object['id']
if '#' in post_id:
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 post_id in recent_posts_cache['index']:
return
@ -2442,7 +2442,7 @@ def update_announce_collection(recent_posts_cache: {},
pprint(post_json_object)
print('DEBUG: post ' + post_filename + ' has no object')
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 debug:
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 getNicknameFromActor
from utils import getDomainFromActor
from utils import removeIdEnding
from utils import remove_id_ending
from blocking import isBlocked
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 += post_json_object['content']
conversationId = removeIdEnding(post_json_object['id'])
conversationId = remove_id_ending(post_json_object['id'])
mediaType = None
mediaUrl = None
@ -131,7 +131,7 @@ def convertVideoToNote(base_dir: str, nickname: str, domain: str,
content += '<a href="' + mediaMagnet + '">🧲</a>'
content += '</p>'
newPostId = removeIdEnding(post_json_object['id'])
newPostId = remove_id_ending(post_json_object['id'])
newPost = {
'@context': post_json_object['@context'],
'id': newPostId + '/activity',

View File

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

View File

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

View File

@ -15,7 +15,7 @@ from utils import dangerousMarkup
from utils import get_config_param
from utils import get_full_domain
from utils import is_editor
from utils import removeIdEnding
from utils import remove_id_ending
from utils import acct_dir
from utils import is_float
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?
currTlStr = None
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):
currTlStr = recent_posts_cache['html'][post_id]
currTlStr = \