mirror of https://gitlab.com/bashrc2/epicyon
Prepare for being able to hide announces
parent
1339ff57b5
commit
76b71b260e
10
announce.py
10
announce.py
|
@ -53,6 +53,16 @@ def no_of_announces(post_json_object: {}) -> int:
|
|||
return len(obj['shares']['items'])
|
||||
|
||||
|
||||
def is_announce(post_json_object: {}) -> bool:
|
||||
"""Is the given post an announce?
|
||||
"""
|
||||
if not post_json_object.get('type'):
|
||||
return False
|
||||
if post_json_object['type'] != 'Announce':
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_self_announce(post_json_object: {}) -> bool:
|
||||
"""Is the given post a self announce?
|
||||
"""
|
||||
|
|
|
@ -799,6 +799,9 @@ def run_daemon(accounts_data_dir: str,
|
|||
|
||||
httpd.starting_daemon = True
|
||||
|
||||
# for each account whether to hide announces
|
||||
httpd.hide_announces = {}
|
||||
|
||||
# number of book events which show on profile screens
|
||||
httpd.no_of_books = no_of_books
|
||||
|
||||
|
|
|
@ -4653,7 +4653,8 @@ def daemon_http_get(self) -> None:
|
|||
self.server.buy_sites,
|
||||
self.server.auto_cw_cache,
|
||||
self.server.onion_domain,
|
||||
self.server.i2p_domain):
|
||||
self.server.i2p_domain,
|
||||
self.server.hide_announces):
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
@ -4834,7 +4835,8 @@ def daemon_http_get(self) -> None:
|
|||
self.server.fitness,
|
||||
self.server.full_width_tl_button_header,
|
||||
self.server.onion_domain,
|
||||
self.server.i2p_domain):
|
||||
self.server.i2p_domain,
|
||||
self.server.hide_announces):
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
@ -5339,7 +5341,8 @@ def daemon_http_get(self) -> None:
|
|||
self.server.auto_cw_cache,
|
||||
self.server.fitness,
|
||||
self.server.onion_domain,
|
||||
self.server.i2p_domain):
|
||||
self.server.i2p_domain,
|
||||
self.server.hide_announces):
|
||||
self.server.getreq_busy = False
|
||||
return
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ def show_media_timeline(self, authorized: bool,
|
|||
fitness: {},
|
||||
full_width_tl_button_header: bool,
|
||||
onion_domain: str,
|
||||
i2p_domain: str) -> bool:
|
||||
i2p_domain: str,
|
||||
hide_announces: {}) -> bool:
|
||||
"""Shows the media timeline
|
||||
"""
|
||||
if '/users/' in path:
|
||||
|
@ -150,6 +151,9 @@ def show_media_timeline(self, authorized: bool,
|
|||
last_post_id = path.split(';lastpost=')[1]
|
||||
if ';' in last_post_id:
|
||||
last_post_id = last_post_id.split(';')[0]
|
||||
show_announces = True
|
||||
if hide_announces.get(nickname):
|
||||
show_announces = False
|
||||
msg = \
|
||||
html_inbox_media(default_timeline,
|
||||
recent_posts_cache,
|
||||
|
@ -195,7 +199,8 @@ def show_media_timeline(self, authorized: bool,
|
|||
min_images_for_accounts,
|
||||
reverse_sequence, last_post_id,
|
||||
buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache,
|
||||
show_announces)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
set_headers(self, 'text/html', msglen,
|
||||
|
@ -1391,7 +1396,8 @@ def show_outbox_timeline(self, authorized: bool,
|
|||
auto_cw_cache: {},
|
||||
fitness: {},
|
||||
onion_domain: str,
|
||||
i2p_domain: str) -> bool:
|
||||
i2p_domain: str,
|
||||
hide_announces: {}) -> bool:
|
||||
"""Shows the outbox timeline
|
||||
"""
|
||||
# get outbox feed for a person
|
||||
|
@ -1452,6 +1458,9 @@ def show_outbox_timeline(self, authorized: bool,
|
|||
reverse_sequence = False
|
||||
if nickname in reverse_sequence_nicknames:
|
||||
reverse_sequence = True
|
||||
show_announces = True
|
||||
if hide_announces.get(nickname):
|
||||
show_announces = False
|
||||
msg = \
|
||||
html_outbox(default_timeline,
|
||||
recent_posts_cache,
|
||||
|
@ -1495,7 +1504,8 @@ def show_outbox_timeline(self, authorized: bool,
|
|||
min_images_for_accounts,
|
||||
reverse_sequence,
|
||||
buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache,
|
||||
show_announces)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
set_headers(self, 'text/html', msglen,
|
||||
|
@ -2186,7 +2196,8 @@ def show_inbox(self, authorized: bool,
|
|||
buy_sites: [],
|
||||
auto_cw_cache: {},
|
||||
onion_domain: str,
|
||||
i2p_domain: str) -> bool:
|
||||
i2p_domain: str,
|
||||
hide_announces: {}) -> bool:
|
||||
"""Shows the inbox timeline
|
||||
"""
|
||||
if '/users/' in path:
|
||||
|
@ -2259,6 +2270,9 @@ def show_inbox(self, authorized: bool,
|
|||
last_post_id = path.split(';lastpost=')[1]
|
||||
if ';' in last_post_id:
|
||||
last_post_id = last_post_id.split(';')[0]
|
||||
show_announces = True
|
||||
if hide_announces.get(nickname):
|
||||
show_announces = False
|
||||
msg = \
|
||||
html_inbox(default_timeline,
|
||||
recent_posts_cache,
|
||||
|
@ -2305,7 +2319,8 @@ def show_inbox(self, authorized: bool,
|
|||
min_images_for_accounts,
|
||||
reverse_sequence, last_post_id,
|
||||
buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache,
|
||||
show_announces)
|
||||
if getreq_start_time:
|
||||
fitness_performance(getreq_start_time, fitness,
|
||||
'_GET', '_show_inbox3',
|
||||
|
|
|
@ -71,6 +71,7 @@ def html_moderation(default_timeline: str,
|
|||
This is what you see when selecting the "mod" timeline
|
||||
"""
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -94,7 +95,7 @@ def html_moderation(default_timeline: str,
|
|||
signing_priv_key_pem, cw_lists, lists_enabled,
|
||||
timezone, bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts, reverse_sequence, None,
|
||||
buy_sites, auto_cw_cache)
|
||||
buy_sites, auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_account_info(translate: {},
|
||||
|
|
|
@ -40,6 +40,7 @@ from webapp_column_left import get_left_column_content
|
|||
from webapp_column_right import get_right_column_content
|
||||
from webapp_headerbuttons import header_buttons_timeline
|
||||
from posts import is_moderator
|
||||
from announce import is_announce
|
||||
from announce import is_self_announce
|
||||
from question import is_html_question
|
||||
from question import is_question
|
||||
|
@ -513,7 +514,8 @@ def html_timeline(default_timeline: str,
|
|||
reverse_sequence: bool,
|
||||
last_post_id: str,
|
||||
buy_sites: {},
|
||||
auto_cw_cache: {}) -> str:
|
||||
auto_cw_cache: {},
|
||||
show_announces: bool) -> str:
|
||||
"""Show the timeline as html
|
||||
"""
|
||||
enable_timing_log = False
|
||||
|
@ -1008,8 +1010,11 @@ def html_timeline(default_timeline: str,
|
|||
if is_person_snoozed(base_dir, nickname, domain,
|
||||
item['actor']):
|
||||
continue
|
||||
if is_self_announce(item):
|
||||
continue
|
||||
if is_announce(item):
|
||||
if not show_announces:
|
||||
continue
|
||||
if is_self_announce(item):
|
||||
continue
|
||||
# is this a poll/vote/question?
|
||||
if not show_vote_posts:
|
||||
if is_question(item):
|
||||
|
@ -1360,6 +1365,7 @@ def html_shares(default_timeline: str,
|
|||
manually_approve_followers = \
|
||||
follower_approval_active(base_dir, nickname, domain)
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
|
@ -1388,7 +1394,7 @@ def html_shares(default_timeline: str,
|
|||
bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_wanted(default_timeline: str,
|
||||
|
@ -1428,6 +1434,7 @@ def html_wanted(default_timeline: str,
|
|||
manually_approve_followers = \
|
||||
follower_approval_active(base_dir, nickname, domain)
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
|
@ -1456,7 +1463,7 @@ def html_wanted(default_timeline: str,
|
|||
bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox(default_timeline: str,
|
||||
|
@ -1492,7 +1499,8 @@ def html_inbox(default_timeline: str,
|
|||
reverse_sequence: bool,
|
||||
last_post_id: str,
|
||||
buy_sites: {},
|
||||
auto_cw_cache: {}) -> str:
|
||||
auto_cw_cache: {},
|
||||
show_announces: bool) -> str:
|
||||
"""Show the inbox as html
|
||||
"""
|
||||
manually_approve_followers = \
|
||||
|
@ -1526,7 +1534,7 @@ def html_inbox(default_timeline: str,
|
|||
bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts,
|
||||
reverse_sequence, last_post_id,
|
||||
buy_sites, auto_cw_cache)
|
||||
buy_sites, auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_bookmarks(default_timeline: str,
|
||||
|
@ -1567,6 +1575,7 @@ def html_bookmarks(default_timeline: str,
|
|||
manually_approve_followers = \
|
||||
follower_approval_active(base_dir, nickname, domain)
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
|
@ -1594,7 +1603,7 @@ def html_bookmarks(default_timeline: str,
|
|||
bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_dms(default_timeline: str,
|
||||
|
@ -1634,6 +1643,7 @@ def html_inbox_dms(default_timeline: str,
|
|||
"""Show the DM timeline as html
|
||||
"""
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = False
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -1659,7 +1669,7 @@ def html_inbox_dms(default_timeline: str,
|
|||
bold_reading, dogwhistles, ua_str,
|
||||
min_images_for_accounts,
|
||||
reverse_sequence, last_post_id,
|
||||
buy_sites, auto_cw_cache)
|
||||
buy_sites, auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_replies(default_timeline: str,
|
||||
|
@ -1699,6 +1709,7 @@ def html_inbox_replies(default_timeline: str,
|
|||
"""Show the replies timeline as html
|
||||
"""
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -1722,7 +1733,7 @@ def html_inbox_replies(default_timeline: str,
|
|||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, last_post_id, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_media(default_timeline: str,
|
||||
|
@ -1758,7 +1769,8 @@ def html_inbox_media(default_timeline: str,
|
|||
reverse_sequence: bool,
|
||||
last_post_id: str,
|
||||
buy_sites: {},
|
||||
auto_cw_cache: {}) -> str:
|
||||
auto_cw_cache: {},
|
||||
show_announces: bool) -> str:
|
||||
"""Show the media timeline as html
|
||||
"""
|
||||
artist = is_artist(base_dir, nickname)
|
||||
|
@ -1785,7 +1797,7 @@ def html_inbox_media(default_timeline: str,
|
|||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, last_post_id, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_blogs(default_timeline: str,
|
||||
|
@ -1825,6 +1837,7 @@ def html_inbox_blogs(default_timeline: str,
|
|||
"""Show the blogs timeline as html
|
||||
"""
|
||||
artist = is_artist(base_dir, nickname)
|
||||
show_announces = True
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -1848,7 +1861,7 @@ def html_inbox_blogs(default_timeline: str,
|
|||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, last_post_id, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_features(default_timeline: str,
|
||||
|
@ -1887,6 +1900,7 @@ def html_inbox_features(default_timeline: str,
|
|||
auto_cw_cache: {}) -> str:
|
||||
"""Show the features timeline as html
|
||||
"""
|
||||
show_announces = True
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -1910,7 +1924,7 @@ def html_inbox_features(default_timeline: str,
|
|||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_inbox_news(default_timeline: str,
|
||||
|
@ -1948,6 +1962,7 @@ def html_inbox_news(default_timeline: str,
|
|||
auto_cw_cache: {}) -> str:
|
||||
"""Show the news timeline as html
|
||||
"""
|
||||
show_announces = True
|
||||
return html_timeline(default_timeline,
|
||||
recent_posts_cache, max_recent_posts,
|
||||
translate, page_number,
|
||||
|
@ -1971,7 +1986,7 @@ def html_inbox_news(default_timeline: str,
|
|||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites,
|
||||
auto_cw_cache)
|
||||
auto_cw_cache, show_announces)
|
||||
|
||||
|
||||
def html_outbox(default_timeline: str,
|
||||
|
@ -2006,7 +2021,8 @@ def html_outbox(default_timeline: str,
|
|||
min_images_for_accounts: [],
|
||||
reverse_sequence: bool,
|
||||
buy_sites: {},
|
||||
auto_cw_cache: {}) -> str:
|
||||
auto_cw_cache: {},
|
||||
show_announces: bool) -> str:
|
||||
"""Show the Outbox as html
|
||||
"""
|
||||
manually_approve_followers = \
|
||||
|
@ -2034,4 +2050,5 @@ def html_outbox(default_timeline: str,
|
|||
shared_items_federated_domains, signing_priv_key_pem,
|
||||
cw_lists, lists_enabled, timezone, bold_reading,
|
||||
dogwhistles, ua_str, min_images_for_accounts,
|
||||
reverse_sequence, None, buy_sites, auto_cw_cache)
|
||||
reverse_sequence, None, buy_sites, auto_cw_cache,
|
||||
show_announces)
|
||||
|
|
Loading…
Reference in New Issue