mirror of https://gitlab.com/bashrc2/epicyon
Add debug for image metadata removal
parent
7d03dcf40b
commit
02b964915b
|
|
@ -1636,7 +1636,8 @@ def get_mentions_from_html(html_text: str, match_str: str) -> []:
|
|||
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
|
||||
form POST
|
||||
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'";'
|
||||
image_start_location = post_bytes.find(image_start_boundary)
|
||||
if image_start_location == -1:
|
||||
if debug:
|
||||
print('DEBUG: image_start_location not found')
|
||||
return None, post_bytes
|
||||
|
||||
# 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_location = media_bytes.find(image_end_boundary)
|
||||
if image_end_location == -1:
|
||||
if debug:
|
||||
print('DEBUG: image_end_location not found')
|
||||
# no ending boundary
|
||||
return media_bytes, post_bytes[:image_start_location]
|
||||
|
||||
|
|
|
|||
|
|
@ -2706,7 +2706,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
|||
print('DEBUG: profile update extracting ' + m_type +
|
||||
' image, zip, csv or font from POST')
|
||||
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 debug:
|
||||
print('DEBUG: profile update ' + m_type +
|
||||
|
|
@ -2786,7 +2786,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
|||
exif_json: list[dict] = []
|
||||
process_meta_data(base_dir, nickname, domain,
|
||||
filename, post_image_filename, city,
|
||||
content_license_url, exif_json)
|
||||
content_license_url, exif_json, debug)
|
||||
if is_a_file(post_image_filename):
|
||||
print('profile update POST ' + m_type +
|
||||
' image, zip or font saved to ' +
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ def _receive_new_post_process_newpost(self, fields: {},
|
|||
chat_url,
|
||||
auto_cw_cache,
|
||||
fields['searchableByDropdown'],
|
||||
curr_session)
|
||||
curr_session, debug)
|
||||
if message_json:
|
||||
if edited_postid:
|
||||
update_edited_post(base_dir, nickname, domain,
|
||||
|
|
@ -379,7 +379,7 @@ def _receive_new_post_process_newblog(self, fields: {},
|
|||
languages_understood,
|
||||
translate, buy_url, chat_url,
|
||||
fields['searchableByDropdown'],
|
||||
curr_session)
|
||||
curr_session, debug)
|
||||
if message_json:
|
||||
if fields['schedulePost']:
|
||||
return NEW_POST_SUCCESS
|
||||
|
|
@ -493,7 +493,8 @@ def _receive_new_post_process_editblog(self, fields: {},
|
|||
video_transcript,
|
||||
city, low_bandwidth,
|
||||
license_url, creator,
|
||||
fields['languagesDropdown'])
|
||||
fields['languagesDropdown'],
|
||||
debug)
|
||||
|
||||
replace_you_tube(post_json_object,
|
||||
yt_replace_domain,
|
||||
|
|
@ -630,7 +631,7 @@ def _receive_new_post_process_newunlisted(self, fields: {},
|
|||
languages_understood,
|
||||
translate, buy_url,
|
||||
chat_url,
|
||||
auto_cw_cache, curr_session)
|
||||
auto_cw_cache, curr_session, debug)
|
||||
if message_json:
|
||||
if edited_postid:
|
||||
update_edited_post(base_dir, nickname, domain,
|
||||
|
|
@ -811,7 +812,7 @@ def _receive_new_post_process_newfollowers(self, fields: {},
|
|||
buy_url, chat_url,
|
||||
auto_cw_cache,
|
||||
fields['searchableByDropdown'],
|
||||
curr_session)
|
||||
curr_session, debug)
|
||||
if message_json:
|
||||
if edited_postid:
|
||||
update_edited_post(base_dir,
|
||||
|
|
@ -1393,7 +1394,7 @@ def _receive_new_post_process_newquestion(self, fields: {},
|
|||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
translate,
|
||||
auto_cw_cache, curr_session)
|
||||
auto_cw_cache, curr_session, debug)
|
||||
if message_json:
|
||||
if debug:
|
||||
print('DEBUG: new Question')
|
||||
|
|
@ -1538,7 +1539,7 @@ def _receive_new_post_process_newreading(self, fields: {},
|
|||
chat_url,
|
||||
auto_cw_cache,
|
||||
fields['searchableByDropdown'],
|
||||
curr_session)
|
||||
curr_session, debug)
|
||||
if message_json:
|
||||
if edited_postid:
|
||||
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:
|
||||
print('DEBUG: extracting media from POST')
|
||||
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 media_bytes:
|
||||
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)
|
||||
process_meta_data(base_dir, nickname, domain,
|
||||
filename, post_image_filename, city,
|
||||
content_license_url, exif_json)
|
||||
content_license_url, exif_json, debug)
|
||||
if is_a_file(post_image_filename):
|
||||
print('POST media saved to ' + post_image_filename)
|
||||
else:
|
||||
|
|
|
|||
21
epicyon.py
21
epicyon.py
|
|
@ -3515,7 +3515,7 @@ def _command_options() -> None:
|
|||
city = 'London, England'
|
||||
if set_profile_image(base_dir, http_prefix, argb.nickname, domain,
|
||||
port, argb.avatar, 'avatar', '128x128', city,
|
||||
argb.content_license_url):
|
||||
argb.content_license_url, debug):
|
||||
print('Avatar added for ' + argb.nickname)
|
||||
else:
|
||||
print('Avatar was not added for ' + argb.nickname)
|
||||
|
|
@ -3531,7 +3531,8 @@ def _command_options() -> None:
|
|||
city = 'London, England'
|
||||
if set_profile_image(base_dir, http_prefix, argb.nickname, domain,
|
||||
port, argb.backgroundImage, 'background',
|
||||
'256x256', city, argb.content_license_url):
|
||||
'256x256', city, argb.content_license_url,
|
||||
debug):
|
||||
print('Background image added for ' + argb.nickname)
|
||||
else:
|
||||
print('Background image was not added for ' + argb.nickname)
|
||||
|
|
@ -3995,7 +3996,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"Zoiks!!!",
|
||||
test_save_to_file,
|
||||
|
|
@ -4014,7 +4015,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"Hey scoob we need like a hundred more #milkshakes",
|
||||
test_save_to_file,
|
||||
|
|
@ -4033,7 +4034,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"Getting kinda spooky around here",
|
||||
test_save_to_file,
|
||||
|
|
@ -4052,7 +4053,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"And they would have gotten away with it too" +
|
||||
"if it wasn't for those pesky hackers",
|
||||
|
|
@ -4072,7 +4073,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"man these centralized sites are like the worst!",
|
||||
test_save_to_file,
|
||||
|
|
@ -4091,7 +4092,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"another mystery solved #test",
|
||||
test_save_to_file,
|
||||
|
|
@ -4110,7 +4111,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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,
|
||||
"let's go bowling",
|
||||
test_save_to_file,
|
||||
|
|
@ -4129,7 +4130,7 @@ def _command_options() -> None:
|
|||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
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)
|
||||
clear_follows(base_dir, nickname, domain, 'following.txt')
|
||||
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
||||
|
|
|
|||
21
media.py
21
media.py
|
|
@ -306,7 +306,8 @@ def replace_twitter(post_json_object: {}, replacement_domain: str,
|
|||
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,
|
||||
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)
|
||||
return
|
||||
if is_a_file('/usr/bin/exiftool'):
|
||||
print('Removing metadata from ' + output_filename + ' using exiftool')
|
||||
cmd = 'exiftool -all= ' + safe_system_string(output_filename)
|
||||
if debug:
|
||||
print('Removing metadata from ' + output_filename +
|
||||
' using exiftool: ' + cmd)
|
||||
os.system(cmd) # nosec
|
||||
elif is_a_file('/usr/bin/mogrify'):
|
||||
print('Removing metadata from ' + output_filename + ' using mogrify')
|
||||
cmd = \
|
||||
'/usr/bin/mogrify -strip ' + safe_system_string(output_filename)
|
||||
if debug:
|
||||
print('Removing metadata from ' + output_filename +
|
||||
' using mogrify: ' + cmd)
|
||||
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,
|
||||
image_filename: str, output_filename: 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
|
||||
if possible, but otherwise just removes it
|
||||
"""
|
||||
# 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
|
||||
_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,
|
||||
content_license_url: str,
|
||||
creator: str,
|
||||
system_language: str) -> {}:
|
||||
system_language: str,
|
||||
debug: bool) -> {}:
|
||||
"""Attaches media to a json object post
|
||||
The description can be None
|
||||
"""
|
||||
|
|
@ -748,7 +755,7 @@ def attach_media(base_dir: str, http_prefix: str,
|
|||
exif_json: list[dict] = []
|
||||
process_meta_data(base_dir, nickname, domain,
|
||||
image_filename, media_filename, city,
|
||||
content_license_url, exif_json)
|
||||
content_license_url, exif_json, debug)
|
||||
if exif_json:
|
||||
# FEP-ee3a
|
||||
# https://codeberg.org/fediverse/fep/src/branch/main/
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
|||
content_license_url: str,
|
||||
media_license_url: str,
|
||||
media_creator: str,
|
||||
session) -> None:
|
||||
session, debug: bool) -> None:
|
||||
"""Converts rss items in a newswire into posts
|
||||
"""
|
||||
if not newswire:
|
||||
|
|
@ -658,7 +658,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
|||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate,
|
||||
buy_url, chat_url, session)
|
||||
buy_url, chat_url, session, debug)
|
||||
if not blog:
|
||||
continue
|
||||
|
||||
|
|
@ -848,7 +848,7 @@ def run_newswire_daemon(base_dir: str, httpd,
|
|||
httpd.low_bandwidth,
|
||||
httpd.content_license_url,
|
||||
httpd.content_license_url, '',
|
||||
httpd.session)
|
||||
httpd.session, httpd.debug)
|
||||
print('Newswire feed converted to ActivityPub')
|
||||
|
||||
if httpd.max_news_posts > 0:
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def set_profile_image(base_dir: str, http_prefix: str,
|
|||
nickname: str, domain: str,
|
||||
port: int, image_filename: str, image_type: 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
|
||||
image for the given person
|
||||
"""
|
||||
|
|
@ -187,7 +187,7 @@ def set_profile_image(base_dir: str, http_prefix: str,
|
|||
exif_json: list[dict] = []
|
||||
process_meta_data(base_dir, nickname, domain,
|
||||
profile_filename, profile_filename, city,
|
||||
content_license_url, exif_json)
|
||||
content_license_url, exif_json, debug)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
|||
53
posts.py
53
posts.py
|
|
@ -1251,7 +1251,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
|||
buy_url: str, chat_url: str, translate: {},
|
||||
searchable_by: [],
|
||||
automatic_quote_approval: str,
|
||||
session) -> {}:
|
||||
session, debug: bool) -> {}:
|
||||
"""Creates a new server-to-server post
|
||||
"""
|
||||
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,
|
||||
media_type, image_description, video_transcript,
|
||||
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_buy_link(new_post['object'], buy_url, translate)
|
||||
_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,
|
||||
translate: {}, searchable_by: [],
|
||||
automatic_quote_approval: str,
|
||||
session) -> {}:
|
||||
session, debug: bool) -> {}:
|
||||
"""Creates a new client-to-server post
|
||||
"""
|
||||
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,
|
||||
city, low_bandwidth,
|
||||
media_license_url, media_creator,
|
||||
system_language)
|
||||
system_language, debug)
|
||||
_attach_post_license(new_post, content_license_url)
|
||||
_attach_buy_link(new_post, buy_url, translate)
|
||||
_attach_chat_link(new_post, chat_url)
|
||||
|
|
@ -1837,7 +1838,8 @@ def create_post_base(base_dir: str,
|
|||
auto_cw_cache: {},
|
||||
searchable_by: [],
|
||||
session,
|
||||
automatic_quote_approval: str) -> {}:
|
||||
automatic_quote_approval: str,
|
||||
debug: bool) -> {}:
|
||||
"""Creates a message
|
||||
"""
|
||||
content = remove_invalid_chars(content)
|
||||
|
|
@ -2018,7 +2020,7 @@ def create_post_base(base_dir: str,
|
|||
media_creator, buy_url, chat_url,
|
||||
translate, searchable_by_list,
|
||||
automatic_quote_approval,
|
||||
session)
|
||||
session, debug)
|
||||
else:
|
||||
new_post = \
|
||||
_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,
|
||||
translate, searchable_by_list,
|
||||
automatic_quote_approval,
|
||||
session)
|
||||
session, debug)
|
||||
|
||||
_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,
|
||||
auto_cw_cache: {},
|
||||
searchable_by: [],
|
||||
session) -> {}:
|
||||
session, debug: bool) -> {}:
|
||||
"""Public post
|
||||
"""
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
|
@ -2330,7 +2332,7 @@ def create_public_post(base_dir: str,
|
|||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url,
|
||||
chat_url, auto_cw_cache, searchable_by,
|
||||
session, automatic_quote_approval)
|
||||
session, automatic_quote_approval, debug)
|
||||
|
||||
|
||||
def create_reading_post(base_dir: str,
|
||||
|
|
@ -2354,7 +2356,7 @@ def create_reading_post(base_dir: str,
|
|||
languages_understood: [], translate: {},
|
||||
buy_url: str, chat_url: str,
|
||||
auto_cw_cache: {},
|
||||
searchable_by: [], session) -> {}:
|
||||
searchable_by: [], session, debug: bool) -> {}:
|
||||
""" reading status post
|
||||
"""
|
||||
content = ''
|
||||
|
|
@ -2396,7 +2398,7 @@ def create_reading_post(base_dir: str,
|
|||
media_license_url, media_creator,
|
||||
languages_understood, translate,
|
||||
buy_url, chat_url, auto_cw_cache,
|
||||
searchable_by, session)
|
||||
searchable_by, session, debug)
|
||||
if post_json_object:
|
||||
post_json_object['object']['tag'] = [{
|
||||
'href': book_url,
|
||||
|
|
@ -2456,7 +2458,7 @@ def create_blog_post(base_dir: str,
|
|||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str, chat_url: str,
|
||||
searchable_by: [], session) -> {}:
|
||||
searchable_by: [], session, debug: bool) -> {}:
|
||||
auto_cw_cache = {}
|
||||
blog_json = \
|
||||
create_public_post(base_dir,
|
||||
|
|
@ -2474,7 +2476,7 @@ def create_blog_post(base_dir: str,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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'])
|
||||
obj_url = remove_html(url_str)
|
||||
if '/@/' not in obj_url:
|
||||
|
|
@ -2494,7 +2496,8 @@ def create_news_post(base_dir: str,
|
|||
low_bandwidth: bool, content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str, chat_url: str, session) -> {}:
|
||||
buy_url: str, chat_url: str, session,
|
||||
debug: bool) -> {}:
|
||||
auto_cw_cache = {}
|
||||
client_to_server: bool = False
|
||||
in_reply_to = None
|
||||
|
|
@ -2522,7 +2525,7 @@ def create_news_post(base_dir: str,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url, chat_url,
|
||||
auto_cw_cache, searchable_by, session)
|
||||
auto_cw_cache, searchable_by, session, debug)
|
||||
blog['object']['type'] = 'Article'
|
||||
return blog
|
||||
|
||||
|
|
@ -2540,7 +2543,8 @@ def create_question_post(base_dir: str,
|
|||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
auto_cw_cache: {}, session) -> {}:
|
||||
auto_cw_cache: {}, session,
|
||||
debug: bool) -> {}:
|
||||
"""Question post with multiple choice options
|
||||
"""
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
|
@ -2581,7 +2585,7 @@ def create_question_post(base_dir: str,
|
|||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url,
|
||||
chat_url, auto_cw_cache, searchable_by,
|
||||
session, automatic_quote_approval)
|
||||
session, automatic_quote_approval, debug)
|
||||
message_json['object']['type'] = 'Question'
|
||||
message_json['object']['oneOf']: list[dict] = []
|
||||
message_json['object']['votersCount'] = 0
|
||||
|
|
@ -2621,7 +2625,7 @@ def create_unlisted_post(base_dir: str,
|
|||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
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.
|
||||
"""
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
|
@ -2661,7 +2665,7 @@ def create_unlisted_post(base_dir: str,
|
|||
languages_understood, translate,
|
||||
buy_url, chat_url, auto_cw_cache,
|
||||
searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
|
||||
|
||||
def create_followers_only_post(base_dir: str,
|
||||
|
|
@ -2685,7 +2689,8 @@ def create_followers_only_post(base_dir: str,
|
|||
translate: {}, buy_url: str,
|
||||
chat_url: str,
|
||||
auto_cw_cache: {},
|
||||
searchable_by: [], session) -> {}:
|
||||
searchable_by: [], session,
|
||||
debug: bool) -> {}:
|
||||
"""Followers only post
|
||||
"""
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
|
@ -2720,7 +2725,7 @@ def create_followers_only_post(base_dir: str,
|
|||
languages_understood, translate,
|
||||
buy_url, chat_url, auto_cw_cache,
|
||||
searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
|
||||
|
||||
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,
|
||||
languages_understood, translate, buy_url, chat_url,
|
||||
auto_cw_cache, searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
# mentioned recipients go into To rather than Cc
|
||||
message_json['to'] = message_json['object']['cc']
|
||||
if not isinstance(message_json['to'], list):
|
||||
|
|
@ -2970,7 +2975,7 @@ def create_report_post(base_dir: str,
|
|||
languages_understood, translate,
|
||||
buy_url, chat_url, auto_cw_cache,
|
||||
searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
if not post_json_object:
|
||||
continue
|
||||
|
||||
|
|
@ -3268,7 +3273,7 @@ def send_post(signing_priv_key_pem: str, project_version: str,
|
|||
languages_understood,
|
||||
translate, buy_url, chat_url,
|
||||
auto_cw_cache, searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
|
||||
# get the senders private key
|
||||
private_key_pem = get_person_key(nickname, domain, base_dir,
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
|||
languages_understood,
|
||||
translate, buy_url, chat_url, auto_cw_cache,
|
||||
searchable_by, session,
|
||||
automatic_quote_approval)
|
||||
automatic_quote_approval, debug)
|
||||
|
||||
auth_header = create_basic_auth_header(from_nickname, password)
|
||||
|
||||
|
|
|
|||
|
|
@ -401,7 +401,8 @@ def add_share(base_dir: str,
|
|||
exif_json: list[dict] = []
|
||||
process_meta_data(base_dir, nickname, domain,
|
||||
image_filename, item_idfile + '.' + ext,
|
||||
city, content_license_url, exif_json)
|
||||
city, content_license_url, exif_json,
|
||||
debug)
|
||||
if move_image:
|
||||
ex_text = \
|
||||
'EX: add_share unable to delete ' + \
|
||||
|
|
|
|||
32
tests.py
32
tests.py
|
|
@ -837,6 +837,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
test_video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"No wise fish would go anywhere without a porpoise",
|
||||
test_save_to_file,
|
||||
|
|
@ -856,7 +857,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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,
|
||||
"Curiouser and curiouser!",
|
||||
test_save_to_file,
|
||||
|
|
@ -876,7 +877,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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,
|
||||
"In the gardens of memory, in the palace " +
|
||||
"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,
|
||||
media_license_url, media_creator,
|
||||
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')
|
||||
global TEST_SERVER_ALICE_RUNNING
|
||||
TEST_SERVER_ALICE_RUNNING = True
|
||||
|
|
@ -1042,6 +1043,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
test_video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"It's your life, live it your way.",
|
||||
test_save_to_file,
|
||||
|
|
@ -1061,7 +1063,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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,
|
||||
"One of the things I've realised is that " +
|
||||
"I am very simple",
|
||||
|
|
@ -1082,7 +1084,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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,
|
||||
"Quantum physics is a bit of a passion of mine",
|
||||
test_save_to_file,
|
||||
|
|
@ -1102,7 +1104,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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')
|
||||
global TEST_SERVER_BOB_RUNNING
|
||||
TEST_SERVER_BOB_RUNNING = True
|
||||
|
|
@ -3213,6 +3215,7 @@ def _test_create_person_account(base_dir: str):
|
|||
auto_cw_cache: dict = {}
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
test_post_json = \
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
content, save_to_file,
|
||||
|
|
@ -3229,7 +3232,7 @@ def _test_create_person_account(base_dir: str):
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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.get('object')
|
||||
assert test_post_json['object']['content']
|
||||
|
|
@ -3259,7 +3262,7 @@ def _test_create_person_account(base_dir: str):
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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.get('object')
|
||||
assert test_post_json['object']['content']
|
||||
|
|
@ -5338,6 +5341,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
|
|||
video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
reply = \
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
content, save_to_file,
|
||||
|
|
@ -5355,7 +5359,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url, chat_url,
|
||||
auto_cw_cache, searchable_by, session)
|
||||
auto_cw_cache, searchable_by, session, debug)
|
||||
# print(str(reply))
|
||||
expected_str = \
|
||||
'<p><span class=\"h-card\">' + \
|
||||
|
|
@ -6425,6 +6429,7 @@ def _test_links_within_post(base_dir: str) -> None:
|
|||
video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
|
||||
post_json_object = \
|
||||
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,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url, chat_url,
|
||||
auto_cw_cache, searchable_by, session)
|
||||
auto_cw_cache, searchable_by, session, debug)
|
||||
|
||||
expected_str = \
|
||||
'<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,
|
||||
media_license_url, media_creator,
|
||||
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']['contentMap'][system_language] == content
|
||||
|
||||
|
|
@ -6516,7 +6521,7 @@ def _test_links_within_post(base_dir: str) -> None:
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
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:
|
||||
print('content1: ' + post_json_object['object']['content'])
|
||||
print('content2: ' + content)
|
||||
|
|
@ -7623,6 +7628,7 @@ def _test_can_replyto(base_dir: str) -> None:
|
|||
video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
debug: bool = True
|
||||
|
||||
post_json_object = \
|
||||
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,
|
||||
media_license_url, media_creator,
|
||||
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
|
||||
curr_date_str = "2021-09-08T20:45:00Z"
|
||||
post_json_object['published'] = curr_date_str
|
||||
|
|
|
|||
Loading…
Reference in New Issue