Snake case

main
Bob Mottram 2021-12-27 23:23:07 +00:00
parent 4246688359
commit 43f77c70ae
4 changed files with 41 additions and 37 deletions

View File

@ -286,7 +286,7 @@ from utils import is_system_account
from utils import set_config_param
from utils import get_config_param
from utils import remove_id_ending
from utils import undoLikesCollectionEntry
from utils import undo_likes_collection_entry
from utils import deletePost
from utils import isBlogPost
from utils import remove_avatar_from_cache
@ -8352,18 +8352,19 @@ class PubServer(BaseHTTPRequestHandler):
recent_posts_cache = self.server.recent_posts_cache
likedPostJson = load_json(likedPostFilename, 0, 1)
if origFilename and origPostUrl:
undoLikesCollectionEntry(recent_posts_cache,
base_dir, likedPostFilename,
likeUrl, undoActor, domain, debug,
likedPostJson)
undo_likes_collection_entry(recent_posts_cache,
base_dir, likedPostFilename,
likeUrl, undoActor,
domain, debug,
likedPostJson)
likeUrl = origPostUrl
likedPostFilename = origFilename
if debug:
print('Removing likes for ' + likedPostFilename)
undoLikesCollectionEntry(recent_posts_cache,
base_dir,
likedPostFilename, likeUrl,
undoActor, domain, debug, None)
undo_likes_collection_entry(recent_posts_cache,
base_dir,
likedPostFilename, likeUrl,
undoActor, domain, debug, None)
if debug:
print('Regenerating html post for changed likes collection')
if likedPostJson:

View File

@ -56,7 +56,7 @@ from utils import deletePost
from utils import removeModerationPostFromIndex
from utils import load_json
from utils import save_json
from utils import undoLikesCollectionEntry
from utils import undo_likes_collection_entry
from utils import undo_reaction_collection_entry
from utils import has_group_type
from utils import local_actor_url
@ -1171,8 +1171,8 @@ def _receiveUndoLike(recent_posts_cache: {},
print('DEBUG: liked post found in inbox. Now undoing.')
likeActor = message_json['actor']
postLikedId = message_json['object']
undoLikesCollectionEntry(recent_posts_cache, base_dir, post_filename,
postLikedId, likeActor, domain, debug, None)
undo_likes_collection_entry(recent_posts_cache, base_dir, post_filename,
postLikedId, likeActor, domain, debug, None)
# regenerate the html
likedPostJson = load_json(post_filename, 0, 1)
if likedPostJson:
@ -1187,10 +1187,12 @@ def _receiveUndoLike(recent_posts_cache: {},
if announceLikedFilename:
postLikedId = announceLikeUrl
post_filename = announceLikedFilename
undoLikesCollectionEntry(recent_posts_cache, base_dir,
post_filename, postLikedId,
likeActor, domain, debug,
None)
undo_likes_collection_entry(recent_posts_cache,
base_dir,
post_filename,
postLikedId,
likeActor, domain, debug,
None)
if likedPostJson:
if debug:
cachedPostFilename = \

View File

@ -21,7 +21,7 @@ from utils import url_permitted
from utils import get_nickname_from_actor
from utils import get_domain_from_actor
from utils import locate_post
from utils import undoLikesCollectionEntry
from utils import undo_likes_collection_entry
from utils import has_group_type
from utils import local_actor_url
from utils import load_json
@ -403,9 +403,9 @@ def outboxUndoLike(recent_posts_cache: {},
print('DEBUG: c2s undo like post not found in inbox or outbox')
print(messageId)
return True
undoLikesCollectionEntry(recent_posts_cache, base_dir, post_filename,
messageId, message_json['actor'],
domain, debug, None)
undo_likes_collection_entry(recent_posts_cache, base_dir, post_filename,
messageId, message_json['actor'],
domain, debug, None)
if debug:
print('DEBUG: post undo liked via c2s - ' + post_filename)

View File

@ -2212,10 +2212,11 @@ def getFileCaseInsensitive(path: str) -> str:
return None
def undoLikesCollectionEntry(recent_posts_cache: {},
base_dir: str, post_filename: str, objectUrl: str,
actor: str, domain: str, debug: bool,
post_json_object: {}) -> None:
def undo_likes_collection_entry(recent_posts_cache: {},
base_dir: str, post_filename: str,
object_url: str,
actor: str, domain: str, debug: bool,
post_json_object: {}) -> None:
"""Undoes a like for a particular actor
"""
if not post_json_object:
@ -2233,7 +2234,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
try:
os.remove(cached_post_filename)
except OSError:
print('EX: undoLikesCollectionEntry ' +
print('EX: undo_likes_collection_entry ' +
'unable to delete cached post ' +
str(cached_post_filename))
remove_post_from_cache(post_json_object, recent_posts_cache)
@ -2251,9 +2252,9 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
return
if not obj['likes'].get('items'):
return
totalItems = 0
total_items = 0
if obj['likes'].get('totalItems'):
totalItems = obj['likes']['totalItems']
total_items = obj['likes']['totalItems']
itemFound = False
for likeItem in obj['likes']['items']:
if likeItem.get('actor'):
@ -2265,7 +2266,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
break
if not itemFound:
return
if totalItems == 1:
if total_items == 1:
if debug:
print('DEBUG: likes was removed from post')
del obj['likes']
@ -2278,7 +2279,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
def undo_reaction_collection_entry(recent_posts_cache: {},
base_dir: str, post_filename: str,
objectUrl: str,
object_url: str,
actor: str, domain: str, debug: bool,
post_json_object: {},
emojiContent: str) -> None:
@ -2317,9 +2318,9 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
return
if not obj['reactions'].get('items'):
return
totalItems = 0
total_items = 0
if obj['reactions'].get('totalItems'):
totalItems = obj['reactions']['totalItems']
total_items = obj['reactions']['totalItems']
itemFound = False
for likeItem in obj['reactions']['items']:
if likeItem.get('actor'):
@ -2332,7 +2333,7 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
break
if not itemFound:
return
if totalItems == 1:
if total_items == 1:
if debug:
print('DEBUG: emoji reaction was removed from post')
del obj['reactions']
@ -2385,9 +2386,9 @@ def undo_announce_collection_entry(recent_posts_cache: {},
return
if not post_json_object['object']['shares'].get('items'):
return
totalItems = 0
total_items = 0
if post_json_object['object']['shares'].get('totalItems'):
totalItems = post_json_object['object']['shares']['totalItems']
total_items = post_json_object['object']['shares']['totalItems']
itemFound = False
for announceItem in post_json_object['object']['shares']['items']:
if announceItem.get('actor'):
@ -2400,7 +2401,7 @@ def undo_announce_collection_entry(recent_posts_cache: {},
break
if not itemFound:
return
if totalItems == 1:
if total_items == 1:
if debug:
print('DEBUG: shares (announcements) ' +
'was removed from post')
@ -2468,11 +2469,11 @@ def update_announce_collection(recent_posts_cache: {},
if announceItem.get('actor'):
if announceItem['actor'] == actor:
return
newAnnounce = {
new_announce = {
'type': 'Announce',
'actor': actor
}
post_json_object['object']['shares']['items'].append(newAnnounce)
post_json_object['object']['shares']['items'].append(new_announce)
itlen = len(post_json_object['object']['shares']['items'])
post_json_object['object']['shares']['totalItems'] = itlen
else: