mirror of
https://github.com/jfmcbrayer/brutaldon
synced 2024-12-22 13:26:14 +01:00
Make sure not to match all toots if you don't have any filters
This commit is contained in:
parent
3bfbc30255
commit
e94eec081a
@ -164,6 +164,8 @@ def get_filters(mastodon, context=None):
|
||||
return []
|
||||
|
||||
def toot_matches_filters(toot, filters=[]):
|
||||
if not filters:
|
||||
return False
|
||||
def maybe_rewrite_filter(filter):
|
||||
if filter.whole_word:
|
||||
return f"\\b{filter.phrase}\\b"
|
||||
@ -171,7 +173,10 @@ def toot_matches_filters(toot, filters=[]):
|
||||
return filter.phrase
|
||||
phrases = [maybe_rewrite_filter(x) for x in filters]
|
||||
pattern = "|".join(phrases)
|
||||
try:
|
||||
return re.search(pattern, toot.spoiler_text + toot.content, re.I)
|
||||
except:
|
||||
return False
|
||||
|
||||
###
|
||||
### View functions
|
||||
|
Loading…
Reference in New Issue
Block a user