merge-requests/30/head
Bob Mottram 2022-06-09 11:03:05 +01:00
parent 9d06389788
commit bc06ceb2b7
2 changed files with 26 additions and 52 deletions

View File

@ -258,14 +258,11 @@ def update_bookmarks_collection(recent_posts_cache: {},
def bookmark_post(recent_posts_cache: {}, def bookmark_post(recent_posts_cache: {},
session, base_dir: str, federation_list: [], base_dir: str, federation_list: [],
nickname: str, domain: str, port: int, nickname: str, domain: str, port: int,
ccList: [], http_prefix: str, cc_list: [], http_prefix: str,
object_url: str, actorBookmarked: str, object_url: str, actor_bookmarked: str,
client_to_server: bool, debug: bool) -> {}:
send_threads: [], post_log: [],
person_cache: {}, cached_webfingers: {},
debug: bool, project_version: str) -> {}:
"""Creates a bookmark """Creates a bookmark
actor is the person doing the bookmarking actor is the person doing the bookmarking
'to' might be a specific person (actor) whose post was bookmarked 'to' might be a specific person (actor) whose post was bookmarked
@ -282,14 +279,14 @@ def bookmark_post(recent_posts_cache: {},
'actor': local_actor_url(http_prefix, nickname, full_domain), 'actor': local_actor_url(http_prefix, nickname, full_domain),
'object': object_url 'object': object_url
} }
if ccList: if cc_list:
if len(ccList) > 0: if len(cc_list) > 0:
new_bookmark_json['cc'] = ccList new_bookmark_json['cc'] = cc_list
# Extract the domain and nickname from a statuses link # Extract the domain and nickname from a statuses link
bookmarked_post_nickname = None bookmarked_post_nickname = None
if actorBookmarked: if actor_bookmarked:
ac_bm = actorBookmarked ac_bm = actor_bookmarked
bookmarked_post_nickname = get_nickname_from_actor(ac_bm) bookmarked_post_nickname = get_nickname_from_actor(ac_bm)
_, _ = get_domain_from_actor(ac_bm) _, _ = get_domain_from_actor(ac_bm)
else: else:
@ -315,14 +312,11 @@ def bookmark_post(recent_posts_cache: {},
def undo_bookmark_post(recent_posts_cache: {}, def undo_bookmark_post(recent_posts_cache: {},
session, base_dir: str, federation_list: [], base_dir: str, federation_list: [],
nickname: str, domain: str, port: int, nickname: str, domain: str, port: int,
ccList: [], http_prefix: str, cc_list: [], http_prefix: str,
object_url: str, actorBookmarked: str, object_url: str, actor_bookmarked: str,
client_to_server: bool, debug: bool) -> {}:
send_threads: [], post_log: [],
person_cache: {}, cached_webfingers: {},
debug: bool, project_version: str) -> {}:
"""Removes a bookmark """Removes a bookmark
actor is the person doing the bookmarking actor is the person doing the bookmarking
'to' might be a specific person (actor) whose post was bookmarked 'to' might be a specific person (actor) whose post was bookmarked
@ -343,15 +337,15 @@ def undo_bookmark_post(recent_posts_cache: {},
'object': object_url 'object': object_url
} }
} }
if ccList: if cc_list:
if len(ccList) > 0: if len(cc_list) > 0:
new_undo_bookmark_json['cc'] = ccList new_undo_bookmark_json['cc'] = cc_list
new_undo_bookmark_json['object']['cc'] = ccList new_undo_bookmark_json['object']['cc'] = cc_list
# Extract the domain and nickname from a statuses link # Extract the domain and nickname from a statuses link
bookmarked_post_nickname = None bookmarked_post_nickname = None
if actorBookmarked: if actor_bookmarked:
ac_bm = actorBookmarked ac_bm = actor_bookmarked
bookmarked_post_nickname = get_nickname_from_actor(ac_bm) bookmarked_post_nickname = get_nickname_from_actor(ac_bm)
_, _ = get_domain_from_actor(ac_bm) _, _ = get_domain_from_actor(ac_bm)
else: else:

View File

@ -9966,20 +9966,10 @@ class PubServer(BaseHTTPRequestHandler):
local_actor_url(http_prefix, self.post_to_nickname, domain_full) local_actor_url(http_prefix, self.post_to_nickname, domain_full)
cc_list = [] cc_list = []
bookmark_post(self.server.recent_posts_cache, bookmark_post(self.server.recent_posts_cache,
curr_session, base_dir, self.server.federation_list,
base_dir, self.post_to_nickname, domain, port,
self.server.federation_list, cc_list, http_prefix, bookmark_url, bookmark_actor,
self.post_to_nickname, self.server.debug)
domain, port,
cc_list,
http_prefix,
bookmark_url, bookmark_actor, False,
self.server.send_threads,
self.server.postLog,
self.server.person_cache,
self.server.cached_webfingers,
self.server.debug,
self.server.project_version)
# clear the icon from the cache so that it gets updated # clear the icon from the cache so that it gets updated
if self.server.iconsCache.get('bookmark.png'): if self.server.iconsCache.get('bookmark.png'):
del self.server.iconsCache['bookmark.png'] del self.server.iconsCache['bookmark.png']
@ -10122,20 +10112,10 @@ class PubServer(BaseHTTPRequestHandler):
local_actor_url(http_prefix, self.post_to_nickname, domain_full) local_actor_url(http_prefix, self.post_to_nickname, domain_full)
cc_list = [] cc_list = []
undo_bookmark_post(self.server.recent_posts_cache, undo_bookmark_post(self.server.recent_posts_cache,
curr_session, base_dir, self.server.federation_list,
base_dir,
self.server.federation_list,
self.post_to_nickname, self.post_to_nickname,
domain, port, domain, port, cc_list, http_prefix,
cc_list, bookmark_url, undo_actor, debug)
http_prefix,
bookmark_url, undo_actor, False,
self.server.send_threads,
self.server.postLog,
self.server.person_cache,
self.server.cached_webfingers,
debug,
self.server.project_version)
# clear the icon from the cache so that it gets updated # clear the icon from the cache so that it gets updated
if self.server.iconsCache.get('bookmark_inactive.png'): if self.server.iconsCache.get('bookmark_inactive.png'):
del self.server.iconsCache['bookmark_inactive.png'] del self.server.iconsCache['bookmark_inactive.png']