restore IGNORE_DOMAIN_BAN janny perm

master
Aevann 2023-06-02 16:48:58 +03:00
parent 498f77bcff
commit 27330e1d62
3 changed files with 20 additions and 17 deletions

View File

@ -504,6 +504,7 @@ PERMS = { # Minimum admin_level to perform action.
'MODS_EVERY_HOLE': 5, 'MODS_EVERY_HOLE': 5,
'MODS_EVERY_GROUP': 5, 'MODS_EVERY_GROUP': 5,
'IGNORE_AWARD_IMMUNITY': 5, 'IGNORE_AWARD_IMMUNITY': 5,
'IGNORE_DOMAIN_BAN': 5,
} }
FEATURES = { FEATURES = {

View File

@ -505,7 +505,18 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_emojis=
links = soup.find_all("a") links = soup.find_all("a")
banned_domains = [x.domain for x in g.db.query(BannedDomain.domain).all()] def error(error):
if chat:
return error, 403
else:
abort(403, error)
if g.v and g.v.admin_level >= PERMS["IGNORE_DOMAIN_BAN"]:
banned_domains = []
else:
if discord_username_regex.match(sanitized):
return error("Stop grooming!")
banned_domains = [x.domain for x in g.db.query(BannedDomain.domain).all()]
for link in links: for link in links:
#remove empty links #remove empty links
@ -559,16 +570,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_emojis=
sanitized = str(soup).replace('<html><body>','').replace('</body></html>','') sanitized = str(soup).replace('<html><body>','').replace('</body></html>','')
def error(error):
if chat:
return error, 403
else:
abort(403, error)
if discord_username_regex.match(sanitized):
return error("Stop grooming!")
if '<pre>' not in sanitized and blackjack != "rules": if '<pre>' not in sanitized and blackjack != "rules":
sanitized = sanitized.replace('\n','') sanitized = sanitized.replace('\n','')

View File

@ -525,12 +525,13 @@ def submit_post(v:User, sub=None):
if repost and FEATURES['REPOST_DETECTION'] and not v.admin_level >= PERMS['POST_BYPASS_REPOST_CHECKING']: if repost and FEATURES['REPOST_DETECTION'] and not v.admin_level >= PERMS['POST_BYPASS_REPOST_CHECKING']:
return {"post_id": repost.id, "success": False} return {"post_id": repost.id, "success": False}
y = tldextract.extract(url).registered_domain + parsed_url.path if v.admin_level < PERMS["IGNORE_DOMAIN_BAN"]:
y = y.lower() y = tldextract.extract(url).registered_domain + parsed_url.path
banned_domains = g.db.query(BannedDomain).all() y = y.lower()
for x in banned_domains: banned_domains = g.db.query(BannedDomain).all()
if y.startswith(x.domain): for x in banned_domains:
abort(400, f'Remove the banned link "{x.domain}" and try again!\nReason for link ban: "{x.reason}"') if y.startswith(x.domain):
abort(400, f'Remove the banned link "{x.domain}" and try again!\nReason for link ban: "{x.reason}"')
if "twitter.com" == domain: if "twitter.com" == domain:
try: try: