mirror of https://gitlab.com/bashrc2/epicyon
Check for twitter content within announces
parent
ab9d2ac24e
commit
61b2207795
18
content.py
18
content.py
|
@ -1941,3 +1941,21 @@ def remove_script(content: str, log_filename: str,
|
||||||
print('EX: cannot append to svg script log')
|
print('EX: cannot append to svg script log')
|
||||||
content = content.replace(text, '')
|
content = content.replace(text, '')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
def reject_twitter_summary(base_dir: str, nickname: str, domain: str,
|
||||||
|
summary: str) -> bool:
|
||||||
|
"""Returns true if the post should be rejected due to twitter
|
||||||
|
existing within the summary
|
||||||
|
"""
|
||||||
|
if not summary:
|
||||||
|
return False
|
||||||
|
remove_twitter = \
|
||||||
|
acct_dir(base_dir, nickname, domain) + '/.removeTwitter'
|
||||||
|
if not os.path.isfile(remove_twitter):
|
||||||
|
return False
|
||||||
|
summary_lower = summary.lower()
|
||||||
|
if 'twitter' in summary_lower or \
|
||||||
|
'birdsite' in summary_lower:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
30
inbox.py
30
inbox.py
|
@ -131,6 +131,7 @@ from conversation import update_conversation
|
||||||
from webapp_hashtagswarm import html_hash_tag_swarm
|
from webapp_hashtagswarm import html_hash_tag_swarm
|
||||||
from person import valid_sending_actor
|
from person import valid_sending_actor
|
||||||
from fitnessFunctions import fitness_performance
|
from fitnessFunctions import fitness_performance
|
||||||
|
from content import reject_twitter_summary
|
||||||
from content import load_dogwhistles
|
from content import load_dogwhistles
|
||||||
from content import valid_url_lengths
|
from content import valid_url_lengths
|
||||||
from content import remove_script
|
from content import remove_script
|
||||||
|
@ -567,22 +568,6 @@ def inbox_permitted_message(domain: str, message_json: {},
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _reject_twitter_summary(base_dir: str, nickname: str, domain: str,
|
|
||||||
summary: str) -> bool:
|
|
||||||
"""Returns true if the post should be rejected due to twitter
|
|
||||||
existing within the summary
|
|
||||||
"""
|
|
||||||
remove_twitter = \
|
|
||||||
acct_dir(base_dir, nickname, domain) + '/.removeTwitter'
|
|
||||||
if not os.path.isfile(remove_twitter):
|
|
||||||
return False
|
|
||||||
summary_lower = summary.lower()
|
|
||||||
if 'twitter' in summary_lower or \
|
|
||||||
'birdsite' in summary_lower:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
post_json_object: {},
|
post_json_object: {},
|
||||||
|
@ -671,13 +656,12 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('WARN: post was filtered out due to content')
|
print('WARN: post was filtered out due to content')
|
||||||
return None
|
return None
|
||||||
if summary_str:
|
if reject_twitter_summary(base_dir, nickname, domain,
|
||||||
if _reject_twitter_summary(base_dir, nickname, domain,
|
summary_str):
|
||||||
summary_str):
|
if debug:
|
||||||
if debug:
|
print('WARN: post was filtered out due to ' +
|
||||||
print('WARN: post was filtered out due to ' +
|
'twitter summary')
|
||||||
'twitter content')
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
original_post_id = None
|
original_post_id = None
|
||||||
if post_json_object.get('id'):
|
if post_json_object.get('id'):
|
||||||
|
|
12
posts.py
12
posts.py
|
@ -79,6 +79,7 @@ from media import get_music_metadata
|
||||||
from media import attach_media
|
from media import attach_media
|
||||||
from media import replace_you_tube
|
from media import replace_you_tube
|
||||||
from media import replace_twitter
|
from media import replace_twitter
|
||||||
|
from content import reject_twitter_summary
|
||||||
from content import words_similarity
|
from content import words_similarity
|
||||||
from content import limit_repeated_words
|
from content import limit_repeated_words
|
||||||
from content import post_tag_exists
|
from content import post_tag_exists
|
||||||
|
@ -5026,15 +5027,20 @@ def download_announce(session, base_dir: str, http_prefix: str,
|
||||||
base_dir, nickname, domain, post_id,
|
base_dir, nickname, domain, post_id,
|
||||||
recent_posts_cache)
|
recent_posts_cache)
|
||||||
return None
|
return None
|
||||||
|
if reject_twitter_summary(base_dir, nickname, domain,
|
||||||
|
summary_str):
|
||||||
|
print('WARN: announced post has twitter summary ' +
|
||||||
|
str(announced_json))
|
||||||
|
_reject_announce(announce_filename,
|
||||||
|
base_dir, nickname, domain, post_id,
|
||||||
|
recent_posts_cache)
|
||||||
|
return None
|
||||||
if invalid_ciphertext(content_str):
|
if invalid_ciphertext(content_str):
|
||||||
print('WARN: announced post contains invalid ciphertext ' +
|
print('WARN: announced post contains invalid ciphertext ' +
|
||||||
str(announced_json))
|
str(announced_json))
|
||||||
_reject_announce(announce_filename,
|
_reject_announce(announce_filename,
|
||||||
base_dir, nickname, domain, post_id,
|
base_dir, nickname, domain, post_id,
|
||||||
recent_posts_cache)
|
recent_posts_cache)
|
||||||
print('WARN: Invalid ciphertext within announce ' +
|
|
||||||
str(announced_json))
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# remove any long words
|
# remove any long words
|
||||||
|
|
Loading…
Reference in New Issue