mirror of https://gitlab.com/bashrc2/epicyon
Sending updates via outbox
parent
91298ab291
commit
c65be9094b
266
outbox.py
266
outbox.py
|
@ -415,148 +415,156 @@ def post_message_to_outbox(session, translate: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: save_post_to_box')
|
print('DEBUG: save_post_to_box')
|
||||||
|
|
||||||
if message_json['type'] != 'Update':
|
is_edited_post = False
|
||||||
outbox_name = 'outbox'
|
if message_json['type'] == 'Update' and \
|
||||||
|
message_json['object']['type'] == 'Note':
|
||||||
|
is_edited_post = True
|
||||||
|
message_json['type'] = 'Create'
|
||||||
|
|
||||||
store_hash_tags(base_dir, post_to_nickname, domain,
|
outbox_name = 'outbox'
|
||||||
http_prefix, domain_full,
|
|
||||||
message_json, translate)
|
|
||||||
|
|
||||||
# if this is a blog post or an event then save to its own box
|
store_hash_tags(base_dir, post_to_nickname, domain,
|
||||||
if message_json['type'] == 'Create':
|
http_prefix, domain_full,
|
||||||
if has_object_dict(message_json):
|
message_json, translate)
|
||||||
if message_json['object'].get('type'):
|
|
||||||
if message_json['object']['type'] == 'Article':
|
|
||||||
outbox_name = 'tlblogs'
|
|
||||||
|
|
||||||
saved_filename = \
|
# if this is a blog post or an event then save to its own box
|
||||||
save_post_to_box(base_dir,
|
if message_json['type'] == 'Create':
|
||||||
http_prefix,
|
if has_object_dict(message_json):
|
||||||
post_id,
|
if message_json['object'].get('type'):
|
||||||
post_to_nickname, domain_full,
|
if message_json['object']['type'] == 'Article':
|
||||||
message_json, outbox_name)
|
outbox_name = 'tlblogs'
|
||||||
if not saved_filename:
|
|
||||||
print('WARN: post not saved to outbox ' + outbox_name)
|
|
||||||
return False
|
|
||||||
|
|
||||||
update_speaker(base_dir, http_prefix,
|
saved_filename = \
|
||||||
post_to_nickname, domain, domain_full,
|
save_post_to_box(base_dir,
|
||||||
message_json, person_cache,
|
http_prefix,
|
||||||
translate, message_json['actor'],
|
post_id,
|
||||||
theme, system_language,
|
post_to_nickname, domain_full,
|
||||||
outbox_name)
|
message_json, outbox_name)
|
||||||
|
if not saved_filename:
|
||||||
|
print('WARN: post not saved to outbox ' + outbox_name)
|
||||||
|
return False
|
||||||
|
|
||||||
# save all instance blogs to the news actor
|
update_speaker(base_dir, http_prefix,
|
||||||
if post_to_nickname != 'news' and outbox_name == 'tlblogs':
|
post_to_nickname, domain, domain_full,
|
||||||
if '/' in saved_filename:
|
message_json, person_cache,
|
||||||
if is_featured_writer(base_dir, post_to_nickname, domain):
|
translate, message_json['actor'],
|
||||||
saved_post_id = saved_filename.split('/')[-1]
|
theme, system_language,
|
||||||
blogs_dir = \
|
outbox_name)
|
||||||
base_dir + '/accounts/news@' + domain + '/tlblogs'
|
|
||||||
if not os.path.isdir(blogs_dir):
|
|
||||||
os.mkdir(blogs_dir)
|
|
||||||
copyfile(saved_filename, blogs_dir + '/' + saved_post_id)
|
|
||||||
inbox_update_index('tlblogs', base_dir,
|
|
||||||
'news@' + domain,
|
|
||||||
saved_filename, debug)
|
|
||||||
|
|
||||||
# clear the citations file if it exists
|
# save all instance blogs to the news actor
|
||||||
citations_filename = \
|
if post_to_nickname != 'news' and outbox_name == 'tlblogs':
|
||||||
base_dir + '/accounts/' + \
|
if '/' in saved_filename:
|
||||||
post_to_nickname + '@' + domain + '/.citations.txt'
|
if is_featured_writer(base_dir, post_to_nickname, domain):
|
||||||
if os.path.isfile(citations_filename):
|
saved_post_id = saved_filename.split('/')[-1]
|
||||||
try:
|
blogs_dir = \
|
||||||
os.remove(citations_filename)
|
base_dir + '/accounts/news@' + domain + '/tlblogs'
|
||||||
except OSError:
|
if not os.path.isdir(blogs_dir):
|
||||||
print('EX: post_message_to_outbox unable to delete ' +
|
os.mkdir(blogs_dir)
|
||||||
citations_filename)
|
copyfile(saved_filename, blogs_dir + '/' + saved_post_id)
|
||||||
|
inbox_update_index('tlblogs', base_dir,
|
||||||
|
'news@' + domain,
|
||||||
|
saved_filename, debug)
|
||||||
|
|
||||||
# The following activity types get added to the index files
|
# clear the citations file if it exists
|
||||||
indexed_activities = (
|
citations_filename = \
|
||||||
'Create', 'Question', 'Note', 'EncryptedMessage', 'Article',
|
base_dir + '/accounts/' + \
|
||||||
'Patch', 'Announce', 'ChatMessage'
|
post_to_nickname + '@' + domain + '/.citations.txt'
|
||||||
)
|
if os.path.isfile(citations_filename):
|
||||||
if message_json['type'] in indexed_activities:
|
try:
|
||||||
indexes = [outbox_name, "inbox"]
|
os.remove(citations_filename)
|
||||||
self_actor = \
|
except OSError:
|
||||||
local_actor_url(http_prefix, post_to_nickname, domain_full)
|
print('EX: post_message_to_outbox unable to delete ' +
|
||||||
for box_name_index in indexes:
|
citations_filename)
|
||||||
if not box_name_index:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# should this also go to the media timeline?
|
# The following activity types get added to the index files
|
||||||
if box_name_index == 'inbox':
|
indexed_activities = (
|
||||||
if is_image_media(session, base_dir, http_prefix,
|
'Create', 'Question', 'Note', 'EncryptedMessage', 'Article',
|
||||||
post_to_nickname, domain,
|
'Patch', 'Announce', 'ChatMessage'
|
||||||
message_json,
|
)
|
||||||
yt_replace_domain,
|
if message_json['type'] in indexed_activities:
|
||||||
twitter_replacement_domain,
|
indexes = [outbox_name, "inbox"]
|
||||||
allow_local_network_access,
|
self_actor = \
|
||||||
recent_posts_cache, debug,
|
local_actor_url(http_prefix, post_to_nickname, domain_full)
|
||||||
system_language,
|
for box_name_index in indexes:
|
||||||
domain_full, person_cache,
|
if not box_name_index:
|
||||||
signing_priv_key_pem,
|
continue
|
||||||
bold_reading):
|
|
||||||
inbox_update_index('tlmedia', base_dir,
|
|
||||||
post_to_nickname + '@' + domain,
|
|
||||||
saved_filename, debug)
|
|
||||||
|
|
||||||
if box_name_index == 'inbox' and outbox_name == 'tlblogs':
|
# should this also go to the media timeline?
|
||||||
continue
|
if box_name_index == 'inbox':
|
||||||
|
if is_image_media(session, base_dir, http_prefix,
|
||||||
# avoid duplicates of the message if already going
|
post_to_nickname, domain,
|
||||||
# back to the inbox of the same account
|
message_json,
|
||||||
if self_actor not in message_json['to']:
|
yt_replace_domain,
|
||||||
# show sent post within the inbox,
|
twitter_replacement_domain,
|
||||||
# as is the typical convention
|
allow_local_network_access,
|
||||||
inbox_update_index(box_name_index, base_dir,
|
recent_posts_cache, debug,
|
||||||
|
system_language,
|
||||||
|
domain_full, person_cache,
|
||||||
|
signing_priv_key_pem,
|
||||||
|
bold_reading):
|
||||||
|
inbox_update_index('tlmedia', base_dir,
|
||||||
post_to_nickname + '@' + domain,
|
post_to_nickname + '@' + domain,
|
||||||
saved_filename, debug)
|
saved_filename, debug)
|
||||||
|
|
||||||
# regenerate the html
|
if box_name_index == 'inbox' and outbox_name == 'tlblogs':
|
||||||
use_cache_only = False
|
continue
|
||||||
page_number = 1
|
|
||||||
show_individual_post_icons = True
|
# avoid duplicates of the message if already going
|
||||||
manually_approve_followers = \
|
# back to the inbox of the same account
|
||||||
follower_approval_active(base_dir,
|
if self_actor not in message_json['to']:
|
||||||
post_to_nickname, domain)
|
# show sent post within the inbox,
|
||||||
timezone = \
|
# as is the typical convention
|
||||||
get_account_timezone(base_dir,
|
inbox_update_index(box_name_index, base_dir,
|
||||||
|
post_to_nickname + '@' + domain,
|
||||||
|
saved_filename, debug)
|
||||||
|
|
||||||
|
# regenerate the html
|
||||||
|
use_cache_only = False
|
||||||
|
page_number = 1
|
||||||
|
show_individual_post_icons = True
|
||||||
|
manually_approve_followers = \
|
||||||
|
follower_approval_active(base_dir,
|
||||||
post_to_nickname, domain)
|
post_to_nickname, domain)
|
||||||
mitm = False
|
timezone = \
|
||||||
if os.path.isfile(saved_filename.replace('.json', '') +
|
get_account_timezone(base_dir,
|
||||||
'.mitm'):
|
post_to_nickname, domain)
|
||||||
mitm = True
|
mitm = False
|
||||||
minimize_all_images = False
|
if os.path.isfile(saved_filename.replace('.json', '') +
|
||||||
if post_to_nickname in min_images_for_accounts:
|
'.mitm'):
|
||||||
minimize_all_images = True
|
mitm = True
|
||||||
individual_post_as_html(signing_priv_key_pem,
|
minimize_all_images = False
|
||||||
False, recent_posts_cache,
|
if post_to_nickname in min_images_for_accounts:
|
||||||
max_recent_posts,
|
minimize_all_images = True
|
||||||
translate, page_number,
|
individual_post_as_html(signing_priv_key_pem,
|
||||||
base_dir, session,
|
False, recent_posts_cache,
|
||||||
cached_webfingers,
|
max_recent_posts,
|
||||||
person_cache,
|
translate, page_number,
|
||||||
post_to_nickname, domain, port,
|
base_dir, session,
|
||||||
message_json, None, True,
|
cached_webfingers,
|
||||||
allow_deletion,
|
person_cache,
|
||||||
http_prefix, __version__,
|
post_to_nickname, domain, port,
|
||||||
box_name_index,
|
message_json, None, True,
|
||||||
yt_replace_domain,
|
allow_deletion,
|
||||||
twitter_replacement_domain,
|
http_prefix, __version__,
|
||||||
show_published_date_only,
|
box_name_index,
|
||||||
peertube_instances,
|
yt_replace_domain,
|
||||||
allow_local_network_access,
|
twitter_replacement_domain,
|
||||||
theme, system_language,
|
show_published_date_only,
|
||||||
max_like_count,
|
peertube_instances,
|
||||||
box_name_index != 'dm',
|
allow_local_network_access,
|
||||||
show_individual_post_icons,
|
theme, system_language,
|
||||||
manually_approve_followers,
|
max_like_count,
|
||||||
False, True, use_cache_only,
|
box_name_index != 'dm',
|
||||||
cw_lists, lists_enabled,
|
show_individual_post_icons,
|
||||||
timezone, mitm,
|
manually_approve_followers,
|
||||||
bold_reading, dogwhistles,
|
False, True, use_cache_only,
|
||||||
minimize_all_images)
|
cw_lists, lists_enabled,
|
||||||
|
timezone, mitm,
|
||||||
|
bold_reading, dogwhistles,
|
||||||
|
minimize_all_images)
|
||||||
|
|
||||||
|
if is_edited_post:
|
||||||
|
message_json['type'] = 'Update'
|
||||||
|
|
||||||
if outbox_announce(recent_posts_cache,
|
if outbox_announce(recent_posts_cache,
|
||||||
base_dir, message_json, debug):
|
base_dir, message_json, debug):
|
||||||
|
|
Loading…
Reference in New Issue