mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
4246688359
commit
43f77c70ae
|
@ -286,7 +286,7 @@ from utils import is_system_account
|
||||||
from utils import set_config_param
|
from utils import set_config_param
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
from utils import undoLikesCollectionEntry
|
from utils import undo_likes_collection_entry
|
||||||
from utils import deletePost
|
from utils import deletePost
|
||||||
from utils import isBlogPost
|
from utils import isBlogPost
|
||||||
from utils import remove_avatar_from_cache
|
from utils import remove_avatar_from_cache
|
||||||
|
@ -8352,15 +8352,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
recent_posts_cache = self.server.recent_posts_cache
|
recent_posts_cache = self.server.recent_posts_cache
|
||||||
likedPostJson = load_json(likedPostFilename, 0, 1)
|
likedPostJson = load_json(likedPostFilename, 0, 1)
|
||||||
if origFilename and origPostUrl:
|
if origFilename and origPostUrl:
|
||||||
undoLikesCollectionEntry(recent_posts_cache,
|
undo_likes_collection_entry(recent_posts_cache,
|
||||||
base_dir, likedPostFilename,
|
base_dir, likedPostFilename,
|
||||||
likeUrl, undoActor, domain, debug,
|
likeUrl, undoActor,
|
||||||
|
domain, debug,
|
||||||
likedPostJson)
|
likedPostJson)
|
||||||
likeUrl = origPostUrl
|
likeUrl = origPostUrl
|
||||||
likedPostFilename = origFilename
|
likedPostFilename = origFilename
|
||||||
if debug:
|
if debug:
|
||||||
print('Removing likes for ' + likedPostFilename)
|
print('Removing likes for ' + likedPostFilename)
|
||||||
undoLikesCollectionEntry(recent_posts_cache,
|
undo_likes_collection_entry(recent_posts_cache,
|
||||||
base_dir,
|
base_dir,
|
||||||
likedPostFilename, likeUrl,
|
likedPostFilename, likeUrl,
|
||||||
undoActor, domain, debug, None)
|
undoActor, domain, debug, None)
|
||||||
|
|
10
inbox.py
10
inbox.py
|
@ -56,7 +56,7 @@ from utils import deletePost
|
||||||
from utils import removeModerationPostFromIndex
|
from utils import removeModerationPostFromIndex
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from utils import save_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 undo_reaction_collection_entry
|
||||||
from utils import has_group_type
|
from utils import has_group_type
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -1171,7 +1171,7 @@ def _receiveUndoLike(recent_posts_cache: {},
|
||||||
print('DEBUG: liked post found in inbox. Now undoing.')
|
print('DEBUG: liked post found in inbox. Now undoing.')
|
||||||
likeActor = message_json['actor']
|
likeActor = message_json['actor']
|
||||||
postLikedId = message_json['object']
|
postLikedId = message_json['object']
|
||||||
undoLikesCollectionEntry(recent_posts_cache, base_dir, post_filename,
|
undo_likes_collection_entry(recent_posts_cache, base_dir, post_filename,
|
||||||
postLikedId, likeActor, domain, debug, None)
|
postLikedId, likeActor, domain, debug, None)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
likedPostJson = load_json(post_filename, 0, 1)
|
likedPostJson = load_json(post_filename, 0, 1)
|
||||||
|
@ -1187,8 +1187,10 @@ def _receiveUndoLike(recent_posts_cache: {},
|
||||||
if announceLikedFilename:
|
if announceLikedFilename:
|
||||||
postLikedId = announceLikeUrl
|
postLikedId = announceLikeUrl
|
||||||
post_filename = announceLikedFilename
|
post_filename = announceLikedFilename
|
||||||
undoLikesCollectionEntry(recent_posts_cache, base_dir,
|
undo_likes_collection_entry(recent_posts_cache,
|
||||||
post_filename, postLikedId,
|
base_dir,
|
||||||
|
post_filename,
|
||||||
|
postLikedId,
|
||||||
likeActor, domain, debug,
|
likeActor, domain, debug,
|
||||||
None)
|
None)
|
||||||
if likedPostJson:
|
if likedPostJson:
|
||||||
|
|
4
like.py
4
like.py
|
@ -21,7 +21,7 @@ from utils import url_permitted
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
from utils import locate_post
|
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 has_group_type
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
|
@ -403,7 +403,7 @@ def outboxUndoLike(recent_posts_cache: {},
|
||||||
print('DEBUG: c2s undo like post not found in inbox or outbox')
|
print('DEBUG: c2s undo like post not found in inbox or outbox')
|
||||||
print(messageId)
|
print(messageId)
|
||||||
return True
|
return True
|
||||||
undoLikesCollectionEntry(recent_posts_cache, base_dir, post_filename,
|
undo_likes_collection_entry(recent_posts_cache, base_dir, post_filename,
|
||||||
messageId, message_json['actor'],
|
messageId, message_json['actor'],
|
||||||
domain, debug, None)
|
domain, debug, None)
|
||||||
if debug:
|
if debug:
|
||||||
|
|
31
utils.py
31
utils.py
|
@ -2212,8 +2212,9 @@ def getFileCaseInsensitive(path: str) -> str:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def undoLikesCollectionEntry(recent_posts_cache: {},
|
def undo_likes_collection_entry(recent_posts_cache: {},
|
||||||
base_dir: str, post_filename: str, objectUrl: str,
|
base_dir: str, post_filename: str,
|
||||||
|
object_url: str,
|
||||||
actor: str, domain: str, debug: bool,
|
actor: str, domain: str, debug: bool,
|
||||||
post_json_object: {}) -> None:
|
post_json_object: {}) -> None:
|
||||||
"""Undoes a like for a particular actor
|
"""Undoes a like for a particular actor
|
||||||
|
@ -2233,7 +2234,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cached_post_filename)
|
os.remove(cached_post_filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: undoLikesCollectionEntry ' +
|
print('EX: undo_likes_collection_entry ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cached_post_filename))
|
str(cached_post_filename))
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
@ -2251,9 +2252,9 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
|
||||||
return
|
return
|
||||||
if not obj['likes'].get('items'):
|
if not obj['likes'].get('items'):
|
||||||
return
|
return
|
||||||
totalItems = 0
|
total_items = 0
|
||||||
if obj['likes'].get('totalItems'):
|
if obj['likes'].get('totalItems'):
|
||||||
totalItems = obj['likes']['totalItems']
|
total_items = obj['likes']['totalItems']
|
||||||
itemFound = False
|
itemFound = False
|
||||||
for likeItem in obj['likes']['items']:
|
for likeItem in obj['likes']['items']:
|
||||||
if likeItem.get('actor'):
|
if likeItem.get('actor'):
|
||||||
|
@ -2265,7 +2266,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
|
||||||
break
|
break
|
||||||
if not itemFound:
|
if not itemFound:
|
||||||
return
|
return
|
||||||
if totalItems == 1:
|
if total_items == 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: likes was removed from post')
|
print('DEBUG: likes was removed from post')
|
||||||
del obj['likes']
|
del obj['likes']
|
||||||
|
@ -2278,7 +2279,7 @@ def undoLikesCollectionEntry(recent_posts_cache: {},
|
||||||
|
|
||||||
def undo_reaction_collection_entry(recent_posts_cache: {},
|
def undo_reaction_collection_entry(recent_posts_cache: {},
|
||||||
base_dir: str, post_filename: str,
|
base_dir: str, post_filename: str,
|
||||||
objectUrl: str,
|
object_url: str,
|
||||||
actor: str, domain: str, debug: bool,
|
actor: str, domain: str, debug: bool,
|
||||||
post_json_object: {},
|
post_json_object: {},
|
||||||
emojiContent: str) -> None:
|
emojiContent: str) -> None:
|
||||||
|
@ -2317,9 +2318,9 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
|
||||||
return
|
return
|
||||||
if not obj['reactions'].get('items'):
|
if not obj['reactions'].get('items'):
|
||||||
return
|
return
|
||||||
totalItems = 0
|
total_items = 0
|
||||||
if obj['reactions'].get('totalItems'):
|
if obj['reactions'].get('totalItems'):
|
||||||
totalItems = obj['reactions']['totalItems']
|
total_items = obj['reactions']['totalItems']
|
||||||
itemFound = False
|
itemFound = False
|
||||||
for likeItem in obj['reactions']['items']:
|
for likeItem in obj['reactions']['items']:
|
||||||
if likeItem.get('actor'):
|
if likeItem.get('actor'):
|
||||||
|
@ -2332,7 +2333,7 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
|
||||||
break
|
break
|
||||||
if not itemFound:
|
if not itemFound:
|
||||||
return
|
return
|
||||||
if totalItems == 1:
|
if total_items == 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: emoji reaction was removed from post')
|
print('DEBUG: emoji reaction was removed from post')
|
||||||
del obj['reactions']
|
del obj['reactions']
|
||||||
|
@ -2385,9 +2386,9 @@ def undo_announce_collection_entry(recent_posts_cache: {},
|
||||||
return
|
return
|
||||||
if not post_json_object['object']['shares'].get('items'):
|
if not post_json_object['object']['shares'].get('items'):
|
||||||
return
|
return
|
||||||
totalItems = 0
|
total_items = 0
|
||||||
if post_json_object['object']['shares'].get('totalItems'):
|
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
|
itemFound = False
|
||||||
for announceItem in post_json_object['object']['shares']['items']:
|
for announceItem in post_json_object['object']['shares']['items']:
|
||||||
if announceItem.get('actor'):
|
if announceItem.get('actor'):
|
||||||
|
@ -2400,7 +2401,7 @@ def undo_announce_collection_entry(recent_posts_cache: {},
|
||||||
break
|
break
|
||||||
if not itemFound:
|
if not itemFound:
|
||||||
return
|
return
|
||||||
if totalItems == 1:
|
if total_items == 1:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: shares (announcements) ' +
|
print('DEBUG: shares (announcements) ' +
|
||||||
'was removed from post')
|
'was removed from post')
|
||||||
|
@ -2468,11 +2469,11 @@ def update_announce_collection(recent_posts_cache: {},
|
||||||
if announceItem.get('actor'):
|
if announceItem.get('actor'):
|
||||||
if announceItem['actor'] == actor:
|
if announceItem['actor'] == actor:
|
||||||
return
|
return
|
||||||
newAnnounce = {
|
new_announce = {
|
||||||
'type': 'Announce',
|
'type': 'Announce',
|
||||||
'actor': actor
|
'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'])
|
itlen = len(post_json_object['object']['shares']['items'])
|
||||||
post_json_object['object']['shares']['totalItems'] = itlen
|
post_json_object['object']['shares']['totalItems'] = itlen
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue