Check for twitter content within announces

main
Bob Mottram 2022-07-27 10:13:30 +01:00
parent ab9d2ac24e
commit 61b2207795
3 changed files with 34 additions and 26 deletions

View File

@ -1941,3 +1941,21 @@ def remove_script(content: str, log_filename: str,
print('EX: cannot append to svg script log')
content = content.replace(text, '')
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

View File

@ -131,6 +131,7 @@ from conversation import update_conversation
from webapp_hashtagswarm import html_hash_tag_swarm
from person import valid_sending_actor
from fitnessFunctions import fitness_performance
from content import reject_twitter_summary
from content import load_dogwhistles
from content import valid_url_lengths
from content import remove_script
@ -567,22 +568,6 @@ def inbox_permitted_message(domain: str, message_json: {},
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,
nickname: str, domain: str,
post_json_object: {},
@ -671,13 +656,12 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
if debug:
print('WARN: post was filtered out due to content')
return None
if summary_str:
if _reject_twitter_summary(base_dir, nickname, domain,
summary_str):
if debug:
print('WARN: post was filtered out due to ' +
'twitter content')
return None
if reject_twitter_summary(base_dir, nickname, domain,
summary_str):
if debug:
print('WARN: post was filtered out due to ' +
'twitter summary')
return None
original_post_id = None
if post_json_object.get('id'):

View File

@ -79,6 +79,7 @@ from media import get_music_metadata
from media import attach_media
from media import replace_you_tube
from media import replace_twitter
from content import reject_twitter_summary
from content import words_similarity
from content import limit_repeated_words
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,
recent_posts_cache)
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):
print('WARN: announced post contains invalid ciphertext ' +
str(announced_json))
_reject_announce(announce_filename,
base_dir, nickname, domain, post_id,
recent_posts_cache)
print('WARN: Invalid ciphertext within announce ' +
str(announced_json))
return None
# remove any long words