mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
92964ef0ce
commit
ce6bae8e04
|
@ -62,6 +62,171 @@ from shares import add_shares_to_actor
|
||||||
from person import get_actor_update_json
|
from person import get_actor_update_json
|
||||||
|
|
||||||
|
|
||||||
|
def _receive_new_post_process_newpost(self, fields: {},
|
||||||
|
base_dir: str, nickname: str,
|
||||||
|
domain: str, domain_full: str, port: int,
|
||||||
|
city: str, http_prefix: str,
|
||||||
|
person_cache: {},
|
||||||
|
content_license_url: str,
|
||||||
|
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_postid: str,
|
||||||
|
edited_published: 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:
|
||||||
|
""" A new post has been received from the New Post screen and
|
||||||
|
is then sent to the outbox
|
||||||
|
"""
|
||||||
|
if not fields.get('pinToProfile'):
|
||||||
|
pin_to_profile = False
|
||||||
|
else:
|
||||||
|
pin_to_profile = True
|
||||||
|
# is the post message empty?
|
||||||
|
if not fields['message']:
|
||||||
|
# remove the pinned content from profile screen
|
||||||
|
undo_pinned_post(base_dir, nickname, domain)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
city = get_spoofed_city(city, base_dir, nickname, domain)
|
||||||
|
|
||||||
|
conversation_id = None
|
||||||
|
if fields.get('conversationId'):
|
||||||
|
conversation_id = fields['conversationId']
|
||||||
|
|
||||||
|
languages_understood = \
|
||||||
|
get_understood_languages(base_dir, http_prefix,
|
||||||
|
nickname, domain_full,
|
||||||
|
person_cache)
|
||||||
|
|
||||||
|
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']
|
||||||
|
message_json = \
|
||||||
|
create_public_post(base_dir, nickname, domain,
|
||||||
|
port,
|
||||||
|
http_prefix,
|
||||||
|
mentions_str + fields['message'],
|
||||||
|
False, False, comments_enabled,
|
||||||
|
filename, attachment_media_type,
|
||||||
|
fields['imageDescription'],
|
||||||
|
video_transcript,
|
||||||
|
city,
|
||||||
|
fields['replyTo'], fields['replyTo'],
|
||||||
|
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 public post ' +
|
||||||
|
str(message_json))
|
||||||
|
if fields['schedulePost']:
|
||||||
|
return 1
|
||||||
|
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,
|
||||||
|
@ -306,124 +471,49 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
chat_url = fields['chatUrl']
|
chat_url = fields['chatUrl']
|
||||||
|
|
||||||
if post_type == 'newpost':
|
if post_type == 'newpost':
|
||||||
if not fields.get('pinToProfile'):
|
return _receive_new_post_process_newpost(
|
||||||
pin_to_profile = False
|
self, fields,
|
||||||
else:
|
base_dir, nickname,
|
||||||
pin_to_profile = True
|
domain, domain_full, port,
|
||||||
# is the post message empty?
|
city, http_prefix,
|
||||||
if not fields['message']:
|
person_cache,
|
||||||
# remove the pinned content from profile screen
|
content_license_url,
|
||||||
undo_pinned_post(base_dir, nickname, domain)
|
mentions_str,
|
||||||
return 1
|
comments_enabled,
|
||||||
|
filename,
|
||||||
city = get_spoofed_city(city, base_dir, nickname, domain)
|
attachment_media_type,
|
||||||
|
low_bandwidth,
|
||||||
conversation_id = None
|
translate,
|
||||||
if fields.get('conversationId'):
|
buy_url,
|
||||||
conversation_id = fields['conversationId']
|
chat_url,
|
||||||
|
auto_cw_cache,
|
||||||
languages_understood = \
|
edited_postid,
|
||||||
get_understood_languages(base_dir, http_prefix,
|
edited_published,
|
||||||
nickname, domain_full,
|
recent_posts_cache,
|
||||||
person_cache)
|
max_mentions,
|
||||||
|
max_emoji,
|
||||||
media_license_url = content_license_url
|
allow_local_network_access,
|
||||||
if fields.get('mediaLicense'):
|
debug,
|
||||||
media_license_url = fields['mediaLicense']
|
system_language,
|
||||||
if '://' not in media_license_url:
|
signing_priv_key_pem,
|
||||||
media_license_url = \
|
max_recent_posts,
|
||||||
license_link_from_name(media_license_url)
|
curr_session,
|
||||||
media_creator = ''
|
cached_webfingers,
|
||||||
if fields.get('mediaCreator'):
|
allow_deletion,
|
||||||
media_creator = fields['mediaCreator']
|
yt_replace_domain,
|
||||||
video_transcript = ''
|
twitter_replacement_domain,
|
||||||
if fields.get('videoTranscript'):
|
show_published_date_only,
|
||||||
video_transcript = fields['videoTranscript']
|
peertube_instances,
|
||||||
message_json = \
|
theme_name,
|
||||||
create_public_post(base_dir, nickname, domain,
|
max_like_count,
|
||||||
port,
|
cw_lists,
|
||||||
http_prefix,
|
dogwhistles,
|
||||||
mentions_str + fields['message'],
|
min_images_for_accounts,
|
||||||
False, False, comments_enabled,
|
max_hashtags,
|
||||||
filename, attachment_media_type,
|
buy_sites,
|
||||||
fields['imageDescription'],
|
project_version,
|
||||||
video_transcript,
|
proxy_type,
|
||||||
city,
|
max_replies)
|
||||||
fields['replyTo'], fields['replyTo'],
|
|
||||||
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 public post ' +
|
|
||||||
str(message_json))
|
|
||||||
if fields['schedulePost']:
|
|
||||||
return 1
|
|
||||||
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 == 'newblog':
|
elif post_type == 'newblog':
|
||||||
# citations button on newblog screen
|
# citations button on newblog screen
|
||||||
if citations_button_press:
|
if citations_button_press:
|
||||||
|
|
Loading…
Reference in New Issue