same as last commit
parent
e1252803aa
commit
ccf6ccd468
|
@ -1027,7 +1027,6 @@ class User(Base):
|
|||
return False
|
||||
if other.sub and not cls.can_see(user, other.subr):
|
||||
return False
|
||||
|
||||
else:
|
||||
if other.parent_submission:
|
||||
return cls.can_see(user, other.post)
|
||||
|
@ -1039,7 +1038,7 @@ class User(Base):
|
|||
if other.top_comment.author_id == user.id: return True
|
||||
return user.admin_level >= PERMS['VIEW_MODMAIL']
|
||||
if other.sentto != user.id:
|
||||
return False
|
||||
return user.admin_level >= PERMS['BLACKJACK_NOTIFICATIONS']
|
||||
elif isinstance(other, Sub):
|
||||
if other.name == 'chudrama': return bool(user) and user.can_see_chudrama
|
||||
if other.name in {'countryclub','splash_mountain'}: return bool(user) and user.can_see_countryclub
|
||||
|
|
|
@ -193,8 +193,6 @@ def execute_blackjack(v, target, body, type):
|
|||
n = Notification(comment_id=target.id, user_id=id)
|
||||
g.db.add(n)
|
||||
|
||||
push_notif(notified_ids, f'Blackjack by @{v.username}', target.body, target)
|
||||
|
||||
extra_info = None
|
||||
|
||||
if extra_info:
|
||||
|
@ -202,6 +200,29 @@ def execute_blackjack(v, target, body, type):
|
|||
send_repeatable_notification(id, f"Blackjack by @{v.username}: {extra_info}")
|
||||
return True
|
||||
|
||||
def execute_anti_grooming(v, c, u):
|
||||
if 'discord' not in c.body and 'groomercord' not in c.body or v.shadowbanned:
|
||||
return
|
||||
|
||||
v.shadowbanned = AUTOJANNY_ID
|
||||
|
||||
ma = ModAction(
|
||||
kind="shadowban",
|
||||
user_id=AUTOJANNY_ID,
|
||||
target_user_id=v.id,
|
||||
_note=f'reason: "Grooming @{u.username}"'
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
v.ban_reason = f"Grooming @{u.username}"
|
||||
g.db.add(v)
|
||||
|
||||
notified_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['BLACKJACK_NOTIFICATIONS'])]
|
||||
|
||||
for id in notified_ids:
|
||||
n = Notification(comment_id=c.id, user_id=id)
|
||||
g.db.add(n)
|
||||
|
||||
def render_emoji(html, regexp, golden, marseys_used, b=False):
|
||||
emojis = list(regexp.finditer(html))
|
||||
captured = set()
|
||||
|
|
|
@ -303,7 +303,7 @@ def notifications(v:User):
|
|||
|
||||
comments = g.db.query(Comment, Notification).join(Notification.comment).join(Comment.author).filter(
|
||||
Notification.user_id == v.id,
|
||||
or_(Comment.sentto == None, Comment.sentto == MODMAIL_ID),
|
||||
or_(Comment.sentto == None, Comment.sentto != v.id),
|
||||
not_(and_(Comment.sentto == MODMAIL_ID, User.is_muted)),
|
||||
)
|
||||
|
||||
|
|
|
@ -536,6 +536,7 @@ def message2(v:User, username:str):
|
|||
g.db.flush()
|
||||
execute_blackjack(v, c, c.body_html, 'message')
|
||||
execute_under_siege(v, c, c.body_html, 'message')
|
||||
execute_anti_grooming(v, c, user)
|
||||
c.top_comment_id = c.id
|
||||
|
||||
if user.id not in bots:
|
||||
|
@ -609,6 +610,7 @@ def messagereply(v:User):
|
|||
g.db.flush()
|
||||
execute_blackjack(v, c, c.body_html, 'message')
|
||||
execute_under_siege(v, c, c.body_html, 'message')
|
||||
execute_anti_grooming(v, c, user)
|
||||
|
||||
if user_id and user_id not in {v.id, MODMAIL_ID} | bots:
|
||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
||||
|
|
Loading…
Reference in New Issue