rename ban_ to remove_

master
Aevann 2024-08-16 17:47:17 +03:00
parent b5d586bc0f
commit b55df5bb32
4 changed files with 16 additions and 12 deletions

View File

@ -452,7 +452,7 @@ def execute_antispam_post_check(title, v, url):
ma = ModAction( ma = ModAction(
user_id=AUTOJANNY_ID, user_id=AUTOJANNY_ID,
target_post_id=post.id, target_post_id=post.id,
kind="ban_post", kind="remove_post",
_note="Spam" _note="Spam"
) )
g.db.add(ma) g.db.add(ma)
@ -512,7 +512,7 @@ def execute_antispam_comment_check(body, v):
ma = ModAction( ma = ModAction(
user_id=AUTOJANNY_ID, user_id=AUTOJANNY_ID,
target_comment_id=comment.id, target_comment_id=comment.id,
kind="ban_comment", kind="remove_comment",
_note="Spam" _note="Spam"
) )
g.db.add(ma) g.db.add(ma)

View File

@ -21,7 +21,7 @@ MODACTION_TYPES = {
"icon": 'fa-badge', "icon": 'fa-badge',
"color": 'bg-danger' "color": 'bg-danger'
}, },
'ban_comment': { 'remove_comment': {
"str": 'removed {self.target_link}', "str": 'removed {self.target_link}',
"icon": 'fa-comment', "icon": 'fa-comment',
"color": 'bg-danger' "color": 'bg-danger'
@ -31,7 +31,7 @@ MODACTION_TYPES = {
"icon": 'fa-globe', "icon": 'fa-globe',
"color": 'bg-danger' "color": 'bg-danger'
}, },
'ban_post': { 'remove_post': {
"str": 'removed post {self.target_link}', "str": 'removed post {self.target_link}',
"icon": 'fa-feather-alt', "icon": 'fa-feather-alt',
"color": 'bg-danger' "color": 'bg-danger'
@ -341,7 +341,7 @@ MODACTION_TYPES = {
"icon": 'fa-snooze', "icon": 'fa-snooze',
"color": 'bg-success' "color": 'bg-success'
}, },
'unban_comment': { 'approve_comment': {
"str": 'reinstated {self.target_link}', "str": 'reinstated {self.target_link}',
"icon": 'fa-comment', "icon": 'fa-comment',
"color": 'bg-success' "color": 'bg-success'
@ -351,7 +351,7 @@ MODACTION_TYPES = {
"icon": 'fa-globe', "icon": 'fa-globe',
"color": 'bg-success' "color": 'bg-success'
}, },
'unban_post': { 'approve_post': {
"str": 'reinstated post {self.target_link}', "str": 'reinstated post {self.target_link}',
"icon": 'fa-feather-alt', "icon": 'fa-feather-alt',
"color": 'bg-success' "color": 'bg-success'

View File

@ -237,10 +237,10 @@ def revert_actions(v, username):
cutoff = int(time.time()) - 86400 cutoff = int(time.time()) - 86400
posts = [x[0] for x in g.db.query(ModAction.target_post_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post')] posts = [x[0] for x in g.db.query(ModAction.target_post_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'remove_post')]
posts = g.db.query(Post).filter(Post.id.in_(posts)).all() posts = g.db.query(Post).filter(Post.id.in_(posts)).all()
comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_comment')] comments = [x[0] for x in g.db.query(ModAction.target_comment_id).filter(ModAction.user_id == revertee.id, ModAction.created_utc > cutoff, ModAction.kind == 'remove_comment')]
comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all() comments = g.db.query(Comment).filter(Comment.id.in_(comments)).all()
for item in posts + comments: for item in posts + comments:
@ -1403,7 +1403,7 @@ def remove_post(post_id, v):
g.db.add(post) g.db.add(post)
ma = ModAction( ma = ModAction(
kind="ban_post", kind="remove_post",
user_id=v.id, user_id=v.id,
target_post_id=post.id, target_post_id=post.id,
) )
@ -1431,7 +1431,7 @@ def approve_post(post_id, v):
if post.is_banned: if post.is_banned:
ma = ModAction( ma = ModAction(
kind="unban_post", kind="approve_post",
user_id=v.id, user_id=v.id,
target_post_id=post.id, target_post_id=post.id,
) )
@ -1614,7 +1614,7 @@ def remove_comment(c_id, v):
comment.ban_reason = v.username comment.ban_reason = v.username
g.db.add(comment) g.db.add(comment)
ma = ModAction( ma = ModAction(
kind="ban_comment", kind="remove_comment",
user_id=v.id, user_id=v.id,
target_comment_id=comment.id, target_comment_id=comment.id,
) )
@ -1641,7 +1641,7 @@ def approve_comment(c_id, v):
if comment.is_banned: if comment.is_banned:
ma = ModAction( ma = ModAction(
kind="unban_comment", kind="approve_comment",
user_id=v.id, user_id=v.id,
target_comment_id=comment.id, target_comment_id=comment.id,
) )

View File

@ -0,0 +1,4 @@
update modactions set kind='remove_comment' where kind='ban_comment';
update modactions set kind='approve_comment' where kind='unban_comment';
update modactions set kind='remove_post' where kind='ban_post';
update modactions set kind='approve_post' where kind='unban_post';