Add debug for image metadata removal

main
bashrc 2026-05-06 22:53:58 +01:00
parent 7d03dcf40b
commit 02b964915b
11 changed files with 99 additions and 73 deletions

View File

@ -1636,7 +1636,8 @@ def get_mentions_from_html(html_text: str, match_str: str) -> []:
return mentions return mentions
def extract_media_in_form_post(post_bytes, boundary, name: str): def extract_media_in_form_post(post_bytes, boundary, name: str,
debug: bool):
"""Extracts the binary encoding for image/video/audio within a http """Extracts the binary encoding for image/video/audio within a http
form POST form POST
Returns the media bytes and the remaining bytes Returns the media bytes and the remaining bytes
@ -1645,6 +1646,8 @@ def extract_media_in_form_post(post_bytes, boundary, name: str):
name.encode('utf8', 'ignore') + b'";' name.encode('utf8', 'ignore') + b'";'
image_start_location = post_bytes.find(image_start_boundary) image_start_location = post_bytes.find(image_start_boundary)
if image_start_location == -1: if image_start_location == -1:
if debug:
print('DEBUG: image_start_location not found')
return None, post_bytes return None, post_bytes
# bytes after the start boundary appears # bytes after the start boundary appears
@ -1654,6 +1657,8 @@ def extract_media_in_form_post(post_bytes, boundary, name: str):
image_end_boundary = boundary.encode('utf8', 'ignore') image_end_boundary = boundary.encode('utf8', 'ignore')
image_end_location = media_bytes.find(image_end_boundary) image_end_location = media_bytes.find(image_end_boundary)
if image_end_location == -1: if image_end_location == -1:
if debug:
print('DEBUG: image_end_location not found')
# no ending boundary # no ending boundary
return media_bytes, post_bytes[:image_start_location] return media_bytes, post_bytes[:image_start_location]

View File

@ -2706,7 +2706,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
print('DEBUG: profile update extracting ' + m_type + print('DEBUG: profile update extracting ' + m_type +
' image, zip, csv or font from POST') ' image, zip, csv or font from POST')
media_bytes, post_bytes = \ media_bytes, post_bytes = \
extract_media_in_form_post(post_bytes, boundary, m_type) extract_media_in_form_post(post_bytes, boundary, m_type, debug)
if media_bytes: if media_bytes:
if debug: if debug:
print('DEBUG: profile update ' + m_type + print('DEBUG: profile update ' + m_type +
@ -2786,7 +2786,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
exif_json: list[dict] = [] exif_json: list[dict] = []
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
filename, post_image_filename, city, filename, post_image_filename, city,
content_license_url, exif_json) content_license_url, exif_json, debug)
if is_a_file(post_image_filename): if is_a_file(post_image_filename):
print('profile update POST ' + m_type + print('profile update POST ' + m_type +
' image, zip or font saved to ' + ' image, zip or font saved to ' +

View File

@ -201,7 +201,7 @@ def _receive_new_post_process_newpost(self, fields: {},
chat_url, chat_url,
auto_cw_cache, auto_cw_cache,
fields['searchableByDropdown'], fields['searchableByDropdown'],
curr_session) curr_session, debug)
if message_json: if message_json:
if edited_postid: if edited_postid:
update_edited_post(base_dir, nickname, domain, update_edited_post(base_dir, nickname, domain,
@ -379,7 +379,7 @@ def _receive_new_post_process_newblog(self, fields: {},
languages_understood, languages_understood,
translate, buy_url, chat_url, translate, buy_url, chat_url,
fields['searchableByDropdown'], fields['searchableByDropdown'],
curr_session) curr_session, debug)
if message_json: if message_json:
if fields['schedulePost']: if fields['schedulePost']:
return NEW_POST_SUCCESS return NEW_POST_SUCCESS
@ -493,7 +493,8 @@ def _receive_new_post_process_editblog(self, fields: {},
video_transcript, video_transcript,
city, low_bandwidth, city, low_bandwidth,
license_url, creator, license_url, creator,
fields['languagesDropdown']) fields['languagesDropdown'],
debug)
replace_you_tube(post_json_object, replace_you_tube(post_json_object,
yt_replace_domain, yt_replace_domain,
@ -630,7 +631,7 @@ def _receive_new_post_process_newunlisted(self, fields: {},
languages_understood, languages_understood,
translate, buy_url, translate, buy_url,
chat_url, chat_url,
auto_cw_cache, curr_session) auto_cw_cache, curr_session, debug)
if message_json: if message_json:
if edited_postid: if edited_postid:
update_edited_post(base_dir, nickname, domain, update_edited_post(base_dir, nickname, domain,
@ -811,7 +812,7 @@ def _receive_new_post_process_newfollowers(self, fields: {},
buy_url, chat_url, buy_url, chat_url,
auto_cw_cache, auto_cw_cache,
fields['searchableByDropdown'], fields['searchableByDropdown'],
curr_session) curr_session, debug)
if message_json: if message_json:
if edited_postid: if edited_postid:
update_edited_post(base_dir, update_edited_post(base_dir,
@ -1393,7 +1394,7 @@ def _receive_new_post_process_newquestion(self, fields: {},
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, languages_understood,
translate, translate,
auto_cw_cache, curr_session) auto_cw_cache, curr_session, debug)
if message_json: if message_json:
if debug: if debug:
print('DEBUG: new Question') print('DEBUG: new Question')
@ -1538,7 +1539,7 @@ def _receive_new_post_process_newreading(self, fields: {},
chat_url, chat_url,
auto_cw_cache, auto_cw_cache,
fields['searchableByDropdown'], fields['searchableByDropdown'],
curr_session) curr_session, debug)
if message_json: if message_json:
if edited_postid: if edited_postid:
update_edited_post(base_dir, nickname, domain, update_edited_post(base_dir, nickname, domain,
@ -1865,7 +1866,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
if debug: if debug:
print('DEBUG: extracting media from POST') print('DEBUG: extracting media from POST')
media_bytes, post_bytes = \ media_bytes, post_bytes = \
extract_media_in_form_post(post_bytes, boundary, 'attachpic') extract_media_in_form_post(post_bytes, boundary, 'attachpic', debug)
if debug: if debug:
if media_bytes: if media_bytes:
print('DEBUG: media was found. ' + print('DEBUG: media was found. ' +
@ -1902,7 +1903,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
city = get_spoofed_city(city, base_dir, nickname, domain) city = get_spoofed_city(city, base_dir, nickname, domain)
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
filename, post_image_filename, city, filename, post_image_filename, city,
content_license_url, exif_json) content_license_url, exif_json, debug)
if is_a_file(post_image_filename): if is_a_file(post_image_filename):
print('POST media saved to ' + post_image_filename) print('POST media saved to ' + post_image_filename)
else: else:

View File

@ -3515,7 +3515,7 @@ def _command_options() -> None:
city = 'London, England' city = 'London, England'
if set_profile_image(base_dir, http_prefix, argb.nickname, domain, if set_profile_image(base_dir, http_prefix, argb.nickname, domain,
port, argb.avatar, 'avatar', '128x128', city, port, argb.avatar, 'avatar', '128x128', city,
argb.content_license_url): argb.content_license_url, debug):
print('Avatar added for ' + argb.nickname) print('Avatar added for ' + argb.nickname)
else: else:
print('Avatar was not added for ' + argb.nickname) print('Avatar was not added for ' + argb.nickname)
@ -3531,7 +3531,8 @@ def _command_options() -> None:
city = 'London, England' city = 'London, England'
if set_profile_image(base_dir, http_prefix, argb.nickname, domain, if set_profile_image(base_dir, http_prefix, argb.nickname, domain,
port, argb.backgroundImage, 'background', port, argb.backgroundImage, 'background',
'256x256', city, argb.content_license_url): '256x256', city, argb.content_license_url,
debug):
print('Background image added for ' + argb.nickname) print('Background image added for ' + argb.nickname)
else: else:
print('Background image was not added for ' + argb.nickname) print('Background image was not added for ' + argb.nickname)
@ -3995,7 +3996,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Zoiks!!!", "Zoiks!!!",
test_save_to_file, test_save_to_file,
@ -4014,7 +4015,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Hey scoob we need like a hundred more #milkshakes", "Hey scoob we need like a hundred more #milkshakes",
test_save_to_file, test_save_to_file,
@ -4033,7 +4034,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"Getting kinda spooky around here", "Getting kinda spooky around here",
test_save_to_file, test_save_to_file,
@ -4052,7 +4053,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"And they would have gotten away with it too" + "And they would have gotten away with it too" +
"if it wasn't for those pesky hackers", "if it wasn't for those pesky hackers",
@ -4072,7 +4073,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"man these centralized sites are like the worst!", "man these centralized sites are like the worst!",
test_save_to_file, test_save_to_file,
@ -4091,7 +4092,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"another mystery solved #test", "another mystery solved #test",
test_save_to_file, test_save_to_file,
@ -4110,7 +4111,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
"let's go bowling", "let's go bowling",
test_save_to_file, test_save_to_file,
@ -4129,7 +4130,7 @@ def _command_options() -> None:
low_bandwidth, argb.content_license_url, low_bandwidth, argb.content_license_url,
argb.media_license_url, argb.media_creator, argb.media_license_url, argb.media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, curr_session) auto_cw_cache, searchable_by, curr_session, debug)
domain_full = domain + ':' + str(port) domain_full = domain + ':' + str(port)
clear_follows(base_dir, nickname, domain, 'following.txt') clear_follows(base_dir, nickname, domain, 'following.txt')
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full, follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,

View File

@ -306,7 +306,8 @@ def replace_twitter(post_json_object: {}, replacement_domain: str,
replacement_domain, system_language) replacement_domain, system_language)
def _remove_meta_data(image_filename: str, output_filename: str) -> None: def _remove_meta_data(image_filename: str, output_filename: str,
debug: bool) -> None:
"""Attempts to do this with pure python didn't work well, """Attempts to do this with pure python didn't work well,
so better to use a dedicated tool if one is installed so better to use a dedicated tool if one is installed
""" """
@ -315,13 +316,17 @@ def _remove_meta_data(image_filename: str, output_filename: str) -> None:
print('ERROR: unable to remove metadata from ' + image_filename) print('ERROR: unable to remove metadata from ' + image_filename)
return return
if is_a_file('/usr/bin/exiftool'): if is_a_file('/usr/bin/exiftool'):
print('Removing metadata from ' + output_filename + ' using exiftool')
cmd = 'exiftool -all= ' + safe_system_string(output_filename) cmd = 'exiftool -all= ' + safe_system_string(output_filename)
if debug:
print('Removing metadata from ' + output_filename +
' using exiftool: ' + cmd)
os.system(cmd) # nosec os.system(cmd) # nosec
elif is_a_file('/usr/bin/mogrify'): elif is_a_file('/usr/bin/mogrify'):
print('Removing metadata from ' + output_filename + ' using mogrify')
cmd = \ cmd = \
'/usr/bin/mogrify -strip ' + safe_system_string(output_filename) '/usr/bin/mogrify -strip ' + safe_system_string(output_filename)
if debug:
print('Removing metadata from ' + output_filename +
' using mogrify: ' + cmd)
os.system(cmd) # nosec os.system(cmd) # nosec
@ -518,12 +523,13 @@ def convert_image_to_low_bandwidth(image_filename: str) -> None:
def process_meta_data(base_dir: str, nickname: str, domain: str, def process_meta_data(base_dir: str, nickname: str, domain: str,
image_filename: str, output_filename: str, image_filename: str, output_filename: str,
city: str, content_license_url: str, city: str, content_license_url: str,
exif_json: list[dict]) -> None: exif_json: list[dict],
debug: bool) -> None:
"""Handles image metadata. This tries to spoof the metadata """Handles image metadata. This tries to spoof the metadata
if possible, but otherwise just removes it if possible, but otherwise just removes it
""" """
# first remove the metadata # first remove the metadata
_remove_meta_data(image_filename, output_filename) _remove_meta_data(image_filename, output_filename, debug)
# now add some spoofed data to misdirect surveillance capitalists # now add some spoofed data to misdirect surveillance capitalists
_spoof_meta_data(base_dir, nickname, domain, output_filename, city, _spoof_meta_data(base_dir, nickname, domain, output_filename, city,
@ -663,7 +669,8 @@ def attach_media(base_dir: str, http_prefix: str,
city: str, low_bandwidth: bool, city: str, low_bandwidth: bool,
content_license_url: str, content_license_url: str,
creator: str, creator: str,
system_language: str) -> {}: system_language: str,
debug: bool) -> {}:
"""Attaches media to a json object post """Attaches media to a json object post
The description can be None The description can be None
""" """
@ -748,7 +755,7 @@ def attach_media(base_dir: str, http_prefix: str,
exif_json: list[dict] = [] exif_json: list[dict] = []
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
image_filename, media_filename, city, image_filename, media_filename, city,
content_license_url, exif_json) content_license_url, exif_json, debug)
if exif_json: if exif_json:
# FEP-ee3a # FEP-ee3a
# https://codeberg.org/fediverse/fep/src/branch/main/ # https://codeberg.org/fediverse/fep/src/branch/main/

View File

@ -554,7 +554,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
content_license_url: str, content_license_url: str,
media_license_url: str, media_license_url: str,
media_creator: str, media_creator: str,
session) -> None: session, debug: bool) -> None:
"""Converts rss items in a newswire into posts """Converts rss items in a newswire into posts
""" """
if not newswire: if not newswire:
@ -658,7 +658,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
content_license_url, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, languages_understood, translate,
buy_url, chat_url, session) buy_url, chat_url, session, debug)
if not blog: if not blog:
continue continue
@ -848,7 +848,7 @@ def run_newswire_daemon(base_dir: str, httpd,
httpd.low_bandwidth, httpd.low_bandwidth,
httpd.content_license_url, httpd.content_license_url,
httpd.content_license_url, '', httpd.content_license_url, '',
httpd.session) httpd.session, httpd.debug)
print('Newswire feed converted to ActivityPub') print('Newswire feed converted to ActivityPub')
if httpd.max_news_posts > 0: if httpd.max_news_posts > 0:

View File

@ -130,7 +130,7 @@ def set_profile_image(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
port: int, image_filename: str, image_type: str, port: int, image_filename: str, image_type: str,
resolution: str, city: str, resolution: str, city: str,
content_license_url: str) -> bool: content_license_url: str, debug: bool) -> bool:
"""Saves the given image file as an avatar or background """Saves the given image file as an avatar or background
image for the given person image for the given person
""" """
@ -187,7 +187,7 @@ def set_profile_image(base_dir: str, http_prefix: str,
exif_json: list[dict] = [] exif_json: list[dict] = []
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
profile_filename, profile_filename, city, profile_filename, profile_filename, city,
content_license_url, exif_json) content_license_url, exif_json, debug)
return True return True
return False return False

View File

@ -1251,7 +1251,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
buy_url: str, chat_url: str, translate: {}, buy_url: str, chat_url: str, translate: {},
searchable_by: [], searchable_by: [],
automatic_quote_approval: str, automatic_quote_approval: str,
session) -> {}: session, debug: bool) -> {}:
"""Creates a new server-to-server post """Creates a new server-to-server post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -1406,7 +1406,8 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
new_post['object'], attach_image_filename, new_post['object'], attach_image_filename,
media_type, image_description, video_transcript, media_type, image_description, video_transcript,
city, low_bandwidth, city, low_bandwidth,
media_license_url, media_creator, system_language) media_license_url, media_creator, system_language,
debug)
_attach_post_license(new_post['object'], content_license_url) _attach_post_license(new_post['object'], content_license_url)
_attach_buy_link(new_post['object'], buy_url, translate) _attach_buy_link(new_post['object'], buy_url, translate)
_attach_chat_link(new_post['object'], chat_url) _attach_chat_link(new_post['object'], chat_url)
@ -1429,7 +1430,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
media_creator: str, buy_url: str, chat_url: str, media_creator: str, buy_url: str, chat_url: str,
translate: {}, searchable_by: [], translate: {}, searchable_by: [],
automatic_quote_approval: str, automatic_quote_approval: str,
session) -> {}: session, debug: bool) -> {}:
"""Creates a new client-to-server post """Creates a new client-to-server post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -1574,7 +1575,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
media_type, image_description, video_transcript, media_type, image_description, video_transcript,
city, low_bandwidth, city, low_bandwidth,
media_license_url, media_creator, media_license_url, media_creator,
system_language) system_language, debug)
_attach_post_license(new_post, content_license_url) _attach_post_license(new_post, content_license_url)
_attach_buy_link(new_post, buy_url, translate) _attach_buy_link(new_post, buy_url, translate)
_attach_chat_link(new_post, chat_url) _attach_chat_link(new_post, chat_url)
@ -1837,7 +1838,8 @@ def create_post_base(base_dir: str,
auto_cw_cache: {}, auto_cw_cache: {},
searchable_by: [], searchable_by: [],
session, session,
automatic_quote_approval: str) -> {}: automatic_quote_approval: str,
debug: bool) -> {}:
"""Creates a message """Creates a message
""" """
content = remove_invalid_chars(content) content = remove_invalid_chars(content)
@ -2018,7 +2020,7 @@ def create_post_base(base_dir: str,
media_creator, buy_url, chat_url, media_creator, buy_url, chat_url,
translate, searchable_by_list, translate, searchable_by_list,
automatic_quote_approval, automatic_quote_approval,
session) session, debug)
else: else:
new_post = \ new_post = \
_create_post_c2s(base_dir, nickname, domain, port, _create_post_c2s(base_dir, nickname, domain, port,
@ -2036,7 +2038,7 @@ def create_post_base(base_dir: str,
media_creator, buy_url, chat_url, media_creator, buy_url, chat_url,
translate, searchable_by_list, translate, searchable_by_list,
automatic_quote_approval, automatic_quote_approval,
session) session, debug)
_create_post_mentions(cc_url, new_post, to_recipients, tags) _create_post_mentions(cc_url, new_post, to_recipients, tags)
@ -2291,7 +2293,7 @@ def create_public_post(base_dir: str,
buy_url: str, chat_url: str, buy_url: str, chat_url: str,
auto_cw_cache: {}, auto_cw_cache: {},
searchable_by: [], searchable_by: [],
session) -> {}: session, debug: bool) -> {}:
"""Public post """Public post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2330,7 +2332,7 @@ def create_public_post(base_dir: str,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, languages_understood, translate, buy_url,
chat_url, auto_cw_cache, searchable_by, chat_url, auto_cw_cache, searchable_by,
session, automatic_quote_approval) session, automatic_quote_approval, debug)
def create_reading_post(base_dir: str, def create_reading_post(base_dir: str,
@ -2354,7 +2356,7 @@ def create_reading_post(base_dir: str,
languages_understood: [], translate: {}, languages_understood: [], translate: {},
buy_url: str, chat_url: str, buy_url: str, chat_url: str,
auto_cw_cache: {}, auto_cw_cache: {},
searchable_by: [], session) -> {}: searchable_by: [], session, debug: bool) -> {}:
""" reading status post """ reading status post
""" """
content = '' content = ''
@ -2396,7 +2398,7 @@ def create_reading_post(base_dir: str,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, languages_understood, translate,
buy_url, chat_url, auto_cw_cache, buy_url, chat_url, auto_cw_cache,
searchable_by, session) searchable_by, session, debug)
if post_json_object: if post_json_object:
post_json_object['object']['tag'] = [{ post_json_object['object']['tag'] = [{
'href': book_url, 'href': book_url,
@ -2456,7 +2458,7 @@ def create_blog_post(base_dir: str,
media_license_url: str, media_creator: str, media_license_url: str, media_creator: str,
languages_understood: [], translate: {}, languages_understood: [], translate: {},
buy_url: str, chat_url: str, buy_url: str, chat_url: str,
searchable_by: [], session) -> {}: searchable_by: [], session, debug: bool) -> {}:
auto_cw_cache = {} auto_cw_cache = {}
blog_json = \ blog_json = \
create_public_post(base_dir, create_public_post(base_dir,
@ -2474,7 +2476,7 @@ def create_blog_post(base_dir: str,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
url_str = get_url_from_post(blog_json['object']['url']) url_str = get_url_from_post(blog_json['object']['url'])
obj_url = remove_html(url_str) obj_url = remove_html(url_str)
if '/@/' not in obj_url: if '/@/' not in obj_url:
@ -2494,7 +2496,8 @@ def create_news_post(base_dir: str,
low_bandwidth: bool, content_license_url: str, low_bandwidth: bool, content_license_url: str,
media_license_url: str, media_creator: str, media_license_url: str, media_creator: str,
languages_understood: [], translate: {}, languages_understood: [], translate: {},
buy_url: str, chat_url: str, session) -> {}: buy_url: str, chat_url: str, session,
debug: bool) -> {}:
auto_cw_cache = {} auto_cw_cache = {}
client_to_server: bool = False client_to_server: bool = False
in_reply_to = None in_reply_to = None
@ -2522,7 +2525,7 @@ def create_news_post(base_dir: str,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
blog['object']['type'] = 'Article' blog['object']['type'] = 'Article'
return blog return blog
@ -2540,7 +2543,8 @@ def create_question_post(base_dir: str,
content_license_url: str, content_license_url: str,
media_license_url: str, media_creator: str, media_license_url: str, media_creator: str,
languages_understood: [], translate: {}, languages_understood: [], translate: {},
auto_cw_cache: {}, session) -> {}: auto_cw_cache: {}, session,
debug: bool) -> {}:
"""Question post with multiple choice options """Question post with multiple choice options
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2581,7 +2585,7 @@ def create_question_post(base_dir: str,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, languages_understood, translate, buy_url,
chat_url, auto_cw_cache, searchable_by, chat_url, auto_cw_cache, searchable_by,
session, automatic_quote_approval) session, automatic_quote_approval, debug)
message_json['object']['type'] = 'Question' message_json['object']['type'] = 'Question'
message_json['object']['oneOf']: list[dict] = [] message_json['object']['oneOf']: list[dict] = []
message_json['object']['votersCount'] = 0 message_json['object']['votersCount'] = 0
@ -2621,7 +2625,7 @@ def create_unlisted_post(base_dir: str,
media_license_url: str, media_creator: str, media_license_url: str, media_creator: str,
languages_understood: [], translate: {}, languages_understood: [], translate: {},
buy_url: str, chat_url: str, buy_url: str, chat_url: str,
auto_cw_cache: {}, session) -> {}: auto_cw_cache: {}, session, debug: bool) -> {}:
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2661,7 +2665,7 @@ def create_unlisted_post(base_dir: str,
languages_understood, translate, languages_understood, translate,
buy_url, chat_url, auto_cw_cache, buy_url, chat_url, auto_cw_cache,
searchable_by, session, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
def create_followers_only_post(base_dir: str, def create_followers_only_post(base_dir: str,
@ -2685,7 +2689,8 @@ def create_followers_only_post(base_dir: str,
translate: {}, buy_url: str, translate: {}, buy_url: str,
chat_url: str, chat_url: str,
auto_cw_cache: {}, auto_cw_cache: {},
searchable_by: [], session) -> {}: searchable_by: [], session,
debug: bool) -> {}:
"""Followers only post """Followers only post
""" """
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
@ -2720,7 +2725,7 @@ def create_followers_only_post(base_dir: str,
languages_understood, translate, languages_understood, translate,
buy_url, chat_url, auto_cw_cache, buy_url, chat_url, auto_cw_cache,
searchable_by, session, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
def get_mentioned_people(base_dir: str, http_prefix: str, def get_mentioned_people(base_dir: str, http_prefix: str,
@ -2826,7 +2831,7 @@ def create_direct_message_post(base_dir: str,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session, auto_cw_cache, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
# mentioned recipients go into To rather than Cc # mentioned recipients go into To rather than Cc
message_json['to'] = message_json['object']['cc'] message_json['to'] = message_json['object']['cc']
if not isinstance(message_json['to'], list): if not isinstance(message_json['to'], list):
@ -2970,7 +2975,7 @@ def create_report_post(base_dir: str,
languages_understood, translate, languages_understood, translate,
buy_url, chat_url, auto_cw_cache, buy_url, chat_url, auto_cw_cache,
searchable_by, session, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
if not post_json_object: if not post_json_object:
continue continue
@ -3268,7 +3273,7 @@ def send_post(signing_priv_key_pem: str, project_version: str,
languages_understood, languages_understood,
translate, buy_url, chat_url, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session, auto_cw_cache, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
# get the senders private key # get the senders private key
private_key_pem = get_person_key(nickname, domain, base_dir, private_key_pem = get_person_key(nickname, domain, base_dir,

View File

@ -152,7 +152,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
languages_understood, languages_understood,
translate, buy_url, chat_url, auto_cw_cache, translate, buy_url, chat_url, auto_cw_cache,
searchable_by, session, searchable_by, session,
automatic_quote_approval) automatic_quote_approval, debug)
auth_header = create_basic_auth_header(from_nickname, password) auth_header = create_basic_auth_header(from_nickname, password)

View File

@ -401,7 +401,8 @@ def add_share(base_dir: str,
exif_json: list[dict] = [] exif_json: list[dict] = []
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
image_filename, item_idfile + '.' + ext, image_filename, item_idfile + '.' + ext,
city, content_license_url, exif_json) city, content_license_url, exif_json,
debug)
if move_image: if move_image:
ex_text = \ ex_text = \
'EX: add_share unable to delete ' + \ 'EX: add_share unable to delete ' + \

View File

@ -837,6 +837,7 @@ def create_server_alice(path: str, domain: str, port: int,
test_video_transcript: str = '' test_video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"No wise fish would go anywhere without a porpoise", "No wise fish would go anywhere without a porpoise",
test_save_to_file, test_save_to_file,
@ -856,7 +857,7 @@ def create_server_alice(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"Curiouser and curiouser!", "Curiouser and curiouser!",
test_save_to_file, test_save_to_file,
@ -876,7 +877,7 @@ def create_server_alice(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"In the gardens of memory, in the palace " + "In the gardens of memory, in the palace " +
"of dreams, that is where you and I shall meet", "of dreams, that is where you and I shall meet",
@ -897,7 +898,7 @@ def create_server_alice(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
regenerate_index_for_box(path, nickname, domain, 'outbox') regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_ALICE_RUNNING global TEST_SERVER_ALICE_RUNNING
TEST_SERVER_ALICE_RUNNING = True TEST_SERVER_ALICE_RUNNING = True
@ -1042,6 +1043,7 @@ def create_server_bob(path: str, domain: str, port: int,
test_video_transcript: str = '' test_video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"It's your life, live it your way.", "It's your life, live it your way.",
test_save_to_file, test_save_to_file,
@ -1061,7 +1063,7 @@ def create_server_bob(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"One of the things I've realised is that " + "One of the things I've realised is that " +
"I am very simple", "I am very simple",
@ -1082,7 +1084,7 @@ def create_server_bob(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
create_public_post(path, nickname, domain, port, http_prefix, create_public_post(path, nickname, domain, port, http_prefix,
"Quantum physics is a bit of a passion of mine", "Quantum physics is a bit of a passion of mine",
test_save_to_file, test_save_to_file,
@ -1102,7 +1104,7 @@ def create_server_bob(path: str, domain: str, port: int,
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
regenerate_index_for_box(path, nickname, domain, 'outbox') regenerate_index_for_box(path, nickname, domain, 'outbox')
global TEST_SERVER_BOB_RUNNING global TEST_SERVER_BOB_RUNNING
TEST_SERVER_BOB_RUNNING = True TEST_SERVER_BOB_RUNNING = True
@ -3213,6 +3215,7 @@ def _test_create_person_account(base_dir: str):
auto_cw_cache: dict = {} auto_cw_cache: dict = {}
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
test_post_json = \ test_post_json = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
content, save_to_file, content, save_to_file,
@ -3229,7 +3232,7 @@ def _test_create_person_account(base_dir: str):
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
assert test_post_json assert test_post_json
assert test_post_json.get('object') assert test_post_json.get('object')
assert test_post_json['object']['content'] assert test_post_json['object']['content']
@ -3259,7 +3262,7 @@ def _test_create_person_account(base_dir: str):
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
assert test_post_json assert test_post_json
assert test_post_json.get('object') assert test_post_json.get('object')
assert test_post_json['object']['content'] assert test_post_json['object']['content']
@ -5338,6 +5341,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
video_transcript: str = '' video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
reply = \ reply = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
content, save_to_file, content, save_to_file,
@ -5355,7 +5359,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
# print(str(reply)) # print(str(reply))
expected_str = \ expected_str = \
'<p><span class=\"h-card\">' + \ '<p><span class=\"h-card\">' + \
@ -6425,6 +6429,7 @@ def _test_links_within_post(base_dir: str) -> None:
video_transcript: str = '' video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
post_json_object = \ post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -6442,7 +6447,7 @@ def _test_links_within_post(base_dir: str) -> None:
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
expected_str = \ expected_str = \
'<p>This is a test post with links.<br><br>' + \ '<p>This is a test post with links.<br><br>' + \
@ -6490,7 +6495,7 @@ def _test_links_within_post(base_dir: str) -> None:
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
assert post_json_object['object']['content'] == content assert post_json_object['object']['content'] == content
assert post_json_object['object']['contentMap'][system_language] == content assert post_json_object['object']['contentMap'][system_language] == content
@ -6516,7 +6521,7 @@ def _test_links_within_post(base_dir: str) -> None:
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
if post_json_object['object']['content'] != content: if post_json_object['object']['content'] != content:
print('content1: ' + post_json_object['object']['content']) print('content1: ' + post_json_object['object']['content'])
print('content2: ' + content) print('content2: ' + content)
@ -7623,6 +7628,7 @@ def _test_can_replyto(base_dir: str) -> None:
video_transcript: str = '' video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
session = None session = None
debug: bool = True
post_json_object = \ post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -7640,7 +7646,7 @@ def _test_can_replyto(base_dir: str) -> None:
low_bandwidth, content_license_url, low_bandwidth, content_license_url,
media_license_url, media_creator, media_license_url, media_creator,
languages_understood, translate, buy_url, chat_url, languages_understood, translate, buy_url, chat_url,
auto_cw_cache, searchable_by, session) auto_cw_cache, searchable_by, session, debug)
# set the date on the post # set the date on the post
curr_date_str = "2021-09-08T20:45:00Z" curr_date_str = "2021-09-08T20:45:00Z"
post_json_object['published'] = curr_date_str post_json_object['published'] = curr_date_str