mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
f2fee34eda
commit
8486209f2b
|
@ -1220,6 +1220,183 @@ def _receive_new_post_process_newquestion(self, fields: {},
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
||||||
|
def _receive_new_post_process_newreading(self, fields: {},
|
||||||
|
post_type: str,
|
||||||
|
content_license_url: str,
|
||||||
|
base_dir: str,
|
||||||
|
http_prefix: str,
|
||||||
|
nickname: str, domain_full: str,
|
||||||
|
person_cache: {}, city: str,
|
||||||
|
domain: str, port: int,
|
||||||
|
mentions_str: str,
|
||||||
|
comments_enabled: bool,
|
||||||
|
filename: str,
|
||||||
|
attachment_media_type: str,
|
||||||
|
low_bandwidth: bool,
|
||||||
|
translate: {}, buy_url: str,
|
||||||
|
chat_url: str,
|
||||||
|
auto_cw_cache: {},
|
||||||
|
edited_published: str,
|
||||||
|
edited_postid: str,
|
||||||
|
recent_posts_cache: {},
|
||||||
|
max_mentions: int,
|
||||||
|
max_emoji: int,
|
||||||
|
allow_local_network_access: bool,
|
||||||
|
debug: bool,
|
||||||
|
system_language: str,
|
||||||
|
signing_priv_key_pem: str,
|
||||||
|
max_recent_posts: int,
|
||||||
|
curr_session,
|
||||||
|
cached_webfingers: {},
|
||||||
|
allow_deletion: bool,
|
||||||
|
yt_replace_domain: str,
|
||||||
|
twitter_replacement_domain: str,
|
||||||
|
show_published_date_only: bool,
|
||||||
|
peertube_instances: [],
|
||||||
|
theme_name: str,
|
||||||
|
max_like_count: int,
|
||||||
|
cw_lists: {},
|
||||||
|
dogwhistles: {},
|
||||||
|
min_images_for_accounts: {},
|
||||||
|
max_hashtags: int,
|
||||||
|
buy_sites: [],
|
||||||
|
project_version: str,
|
||||||
|
proxy_type: str,
|
||||||
|
max_replies: int) -> int:
|
||||||
|
"""Reading status post has been received from New Post screen
|
||||||
|
and is then sent to the outbox
|
||||||
|
"""
|
||||||
|
if not fields.get('readingupdatetype'):
|
||||||
|
print(post_type + ' no readingupdatetype')
|
||||||
|
return -1
|
||||||
|
if fields['readingupdatetype'] not in ('readingupdatewant',
|
||||||
|
'readingupdateread',
|
||||||
|
'readingupdatefinished',
|
||||||
|
'readingupdaterating'):
|
||||||
|
print(post_type + ' not recognised ' +
|
||||||
|
fields['readingupdatetype'])
|
||||||
|
return -1
|
||||||
|
if not fields.get('booktitle'):
|
||||||
|
print(post_type + ' no booktitle')
|
||||||
|
return -1
|
||||||
|
if not fields.get('bookurl'):
|
||||||
|
print(post_type + ' no bookurl')
|
||||||
|
return -1
|
||||||
|
book_rating = 0.0
|
||||||
|
if fields.get('bookrating'):
|
||||||
|
if isinstance(fields['bookrating'], (float, int)):
|
||||||
|
book_rating = fields['bookrating']
|
||||||
|
media_license_url = content_license_url
|
||||||
|
if fields.get('mediaLicense'):
|
||||||
|
media_license_url = fields['mediaLicense']
|
||||||
|
if '://' not in media_license_url:
|
||||||
|
media_license_url = \
|
||||||
|
license_link_from_name(media_license_url)
|
||||||
|
media_creator = ''
|
||||||
|
if fields.get('mediaCreator'):
|
||||||
|
media_creator = fields['mediaCreator']
|
||||||
|
video_transcript = ''
|
||||||
|
if fields.get('videoTranscript'):
|
||||||
|
video_transcript = fields['videoTranscript']
|
||||||
|
conversation_id = None
|
||||||
|
languages_understood = \
|
||||||
|
get_understood_languages(base_dir, http_prefix,
|
||||||
|
nickname, domain_full,
|
||||||
|
person_cache)
|
||||||
|
city = get_spoofed_city(city, base_dir,
|
||||||
|
nickname, domain)
|
||||||
|
msg_str = fields['readingupdatetype']
|
||||||
|
# reading status
|
||||||
|
message_json = \
|
||||||
|
create_reading_post(base_dir, nickname, domain,
|
||||||
|
port, http_prefix,
|
||||||
|
mentions_str, msg_str,
|
||||||
|
fields['booktitle'],
|
||||||
|
fields['bookurl'],
|
||||||
|
book_rating,
|
||||||
|
False, False, comments_enabled,
|
||||||
|
filename, attachment_media_type,
|
||||||
|
fields['imageDescription'],
|
||||||
|
video_transcript,
|
||||||
|
city, None, None,
|
||||||
|
fields['subject'],
|
||||||
|
fields['schedulePost'],
|
||||||
|
fields['eventDate'],
|
||||||
|
fields['eventTime'],
|
||||||
|
fields['eventEndTime'],
|
||||||
|
fields['location'], False,
|
||||||
|
fields['languagesDropdown'],
|
||||||
|
conversation_id,
|
||||||
|
low_bandwidth,
|
||||||
|
content_license_url,
|
||||||
|
media_license_url, media_creator,
|
||||||
|
languages_understood,
|
||||||
|
translate, buy_url,
|
||||||
|
chat_url,
|
||||||
|
auto_cw_cache)
|
||||||
|
if message_json:
|
||||||
|
if edited_postid:
|
||||||
|
update_edited_post(base_dir, nickname, domain,
|
||||||
|
message_json,
|
||||||
|
edited_published,
|
||||||
|
edited_postid,
|
||||||
|
recent_posts_cache,
|
||||||
|
'outbox',
|
||||||
|
max_mentions,
|
||||||
|
max_emoji,
|
||||||
|
allow_local_network_access,
|
||||||
|
debug,
|
||||||
|
system_language,
|
||||||
|
http_prefix,
|
||||||
|
domain_full,
|
||||||
|
person_cache,
|
||||||
|
signing_priv_key_pem,
|
||||||
|
max_recent_posts,
|
||||||
|
translate,
|
||||||
|
curr_session,
|
||||||
|
cached_webfingers,
|
||||||
|
port,
|
||||||
|
allow_deletion,
|
||||||
|
yt_replace_domain,
|
||||||
|
twitter_replacement_domain,
|
||||||
|
show_published_date_only,
|
||||||
|
peertube_instances,
|
||||||
|
theme_name,
|
||||||
|
max_like_count,
|
||||||
|
cw_lists,
|
||||||
|
dogwhistles,
|
||||||
|
min_images_for_accounts,
|
||||||
|
max_hashtags,
|
||||||
|
buy_sites,
|
||||||
|
auto_cw_cache)
|
||||||
|
print('DEBUG: sending edited reading status post ' +
|
||||||
|
str(message_json))
|
||||||
|
if fields['schedulePost']:
|
||||||
|
return 1
|
||||||
|
if not fields.get('pinToProfile'):
|
||||||
|
pin_to_profile = False
|
||||||
|
else:
|
||||||
|
pin_to_profile = True
|
||||||
|
if pin_to_profile:
|
||||||
|
sys_language = system_language
|
||||||
|
content_str = \
|
||||||
|
get_base_content_from_post(message_json,
|
||||||
|
sys_language)
|
||||||
|
pin_post2(base_dir, nickname, domain, content_str)
|
||||||
|
return 1
|
||||||
|
if post_to_outbox(self, message_json,
|
||||||
|
project_version,
|
||||||
|
nickname,
|
||||||
|
curr_session, proxy_type):
|
||||||
|
populate_replies(base_dir, http_prefix,
|
||||||
|
domain_full,
|
||||||
|
message_json,
|
||||||
|
max_replies,
|
||||||
|
debug)
|
||||||
|
return 1
|
||||||
|
return -1
|
||||||
|
|
||||||
|
|
||||||
def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
length: int, post_bytes, boundary: str,
|
length: int, post_bytes, boundary: str,
|
||||||
calling_domain: str, cookie: str,
|
calling_domain: str, cookie: str,
|
||||||
|
@ -1742,135 +1919,50 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
debug, project_version, curr_session,
|
debug, project_version, curr_session,
|
||||||
proxy_type)
|
proxy_type)
|
||||||
elif post_type in ('newreadingstatus'):
|
elif post_type in ('newreadingstatus'):
|
||||||
if not fields.get('readingupdatetype'):
|
return _receive_new_post_process_newreading(
|
||||||
print(post_type + ' no readingupdatetype')
|
self, fields,
|
||||||
return -1
|
post_type,
|
||||||
if fields['readingupdatetype'] not in ('readingupdatewant',
|
content_license_url,
|
||||||
'readingupdateread',
|
base_dir,
|
||||||
'readingupdatefinished',
|
http_prefix,
|
||||||
'readingupdaterating'):
|
nickname, domain_full,
|
||||||
print(post_type + ' not recognised ' +
|
person_cache, city,
|
||||||
fields['readingupdatetype'])
|
domain, port,
|
||||||
return -1
|
mentions_str,
|
||||||
if not fields.get('booktitle'):
|
comments_enabled,
|
||||||
print(post_type + ' no booktitle')
|
filename,
|
||||||
return -1
|
attachment_media_type,
|
||||||
if not fields.get('bookurl'):
|
low_bandwidth,
|
||||||
print(post_type + ' no bookurl')
|
translate, buy_url,
|
||||||
return -1
|
chat_url,
|
||||||
book_rating = 0.0
|
auto_cw_cache,
|
||||||
if fields.get('bookrating'):
|
edited_published,
|
||||||
if isinstance(fields['bookrating'], (float, int)):
|
edited_postid,
|
||||||
book_rating = fields['bookrating']
|
recent_posts_cache,
|
||||||
media_license_url = content_license_url
|
max_mentions,
|
||||||
if fields.get('mediaLicense'):
|
max_emoji,
|
||||||
media_license_url = fields['mediaLicense']
|
allow_local_network_access,
|
||||||
if '://' not in media_license_url:
|
debug,
|
||||||
media_license_url = \
|
system_language,
|
||||||
license_link_from_name(media_license_url)
|
signing_priv_key_pem,
|
||||||
media_creator = ''
|
max_recent_posts,
|
||||||
if fields.get('mediaCreator'):
|
curr_session,
|
||||||
media_creator = fields['mediaCreator']
|
cached_webfingers,
|
||||||
video_transcript = ''
|
allow_deletion,
|
||||||
if fields.get('videoTranscript'):
|
yt_replace_domain,
|
||||||
video_transcript = fields['videoTranscript']
|
twitter_replacement_domain,
|
||||||
conversation_id = None
|
show_published_date_only,
|
||||||
languages_understood = \
|
peertube_instances,
|
||||||
get_understood_languages(base_dir, http_prefix,
|
theme_name,
|
||||||
nickname, domain_full,
|
max_like_count,
|
||||||
person_cache)
|
cw_lists,
|
||||||
city = get_spoofed_city(city, base_dir,
|
dogwhistles,
|
||||||
nickname, domain)
|
min_images_for_accounts,
|
||||||
msg_str = fields['readingupdatetype']
|
max_hashtags,
|
||||||
# reading status
|
buy_sites,
|
||||||
message_json = \
|
project_version,
|
||||||
create_reading_post(base_dir, nickname, domain,
|
proxy_type,
|
||||||
port, http_prefix,
|
max_replies)
|
||||||
mentions_str, msg_str,
|
|
||||||
fields['booktitle'],
|
|
||||||
fields['bookurl'],
|
|
||||||
book_rating,
|
|
||||||
False, False, comments_enabled,
|
|
||||||
filename, attachment_media_type,
|
|
||||||
fields['imageDescription'],
|
|
||||||
video_transcript,
|
|
||||||
city, None, None,
|
|
||||||
fields['subject'],
|
|
||||||
fields['schedulePost'],
|
|
||||||
fields['eventDate'],
|
|
||||||
fields['eventTime'],
|
|
||||||
fields['eventEndTime'],
|
|
||||||
fields['location'], False,
|
|
||||||
fields['languagesDropdown'],
|
|
||||||
conversation_id,
|
|
||||||
low_bandwidth,
|
|
||||||
content_license_url,
|
|
||||||
media_license_url, media_creator,
|
|
||||||
languages_understood,
|
|
||||||
translate, buy_url,
|
|
||||||
chat_url,
|
|
||||||
auto_cw_cache)
|
|
||||||
if message_json:
|
|
||||||
if edited_postid:
|
|
||||||
update_edited_post(base_dir, nickname, domain,
|
|
||||||
message_json,
|
|
||||||
edited_published,
|
|
||||||
edited_postid,
|
|
||||||
recent_posts_cache,
|
|
||||||
'outbox',
|
|
||||||
max_mentions,
|
|
||||||
max_emoji,
|
|
||||||
allow_local_network_access,
|
|
||||||
debug,
|
|
||||||
system_language,
|
|
||||||
http_prefix,
|
|
||||||
domain_full,
|
|
||||||
person_cache,
|
|
||||||
signing_priv_key_pem,
|
|
||||||
max_recent_posts,
|
|
||||||
translate,
|
|
||||||
curr_session,
|
|
||||||
cached_webfingers,
|
|
||||||
port,
|
|
||||||
allow_deletion,
|
|
||||||
yt_replace_domain,
|
|
||||||
twitter_replacement_domain,
|
|
||||||
show_published_date_only,
|
|
||||||
peertube_instances,
|
|
||||||
theme_name,
|
|
||||||
max_like_count,
|
|
||||||
cw_lists,
|
|
||||||
dogwhistles,
|
|
||||||
min_images_for_accounts,
|
|
||||||
max_hashtags,
|
|
||||||
buy_sites,
|
|
||||||
auto_cw_cache)
|
|
||||||
print('DEBUG: sending edited reading status post ' +
|
|
||||||
str(message_json))
|
|
||||||
if fields['schedulePost']:
|
|
||||||
return 1
|
|
||||||
if not fields.get('pinToProfile'):
|
|
||||||
pin_to_profile = False
|
|
||||||
else:
|
|
||||||
pin_to_profile = True
|
|
||||||
if pin_to_profile:
|
|
||||||
sys_language = system_language
|
|
||||||
content_str = \
|
|
||||||
get_base_content_from_post(message_json,
|
|
||||||
sys_language)
|
|
||||||
pin_post2(base_dir, nickname, domain, content_str)
|
|
||||||
return 1
|
|
||||||
if post_to_outbox(self, message_json,
|
|
||||||
project_version,
|
|
||||||
nickname,
|
|
||||||
curr_session, proxy_type):
|
|
||||||
populate_replies(base_dir, http_prefix,
|
|
||||||
domain_full,
|
|
||||||
message_json,
|
|
||||||
max_replies,
|
|
||||||
debug)
|
|
||||||
return 1
|
|
||||||
return -1
|
|
||||||
elif post_type in ('newshare', 'newwanted'):
|
elif post_type in ('newshare', 'newwanted'):
|
||||||
if not fields.get('itemQty'):
|
if not fields.get('itemQty'):
|
||||||
print(post_type + ' no itemQty')
|
print(post_type + ' no itemQty')
|
||||||
|
@ -1987,7 +2079,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
||||||
def receive_new_post(self, post_type: str, path: str,
|
def receive_new_post(self, post_type, path: str,
|
||||||
calling_domain: str, cookie: str,
|
calling_domain: str, cookie: str,
|
||||||
content_license_url: str,
|
content_license_url: str,
|
||||||
curr_session, proxy_type: str,
|
curr_session, proxy_type: str,
|
||||||
|
|
Loading…
Reference in New Issue