Rejigger the Mod/Report state system.
This commit is contained in:
parent
31ebdd0213
commit
ccf809406e
36 changed files with 492 additions and 226 deletions
|
@ -9,6 +9,7 @@ from sqlalchemy.orm import Query, aliased
|
|||
from sqlalchemy.sql.expression import alias, func, text
|
||||
|
||||
from files.classes import Comment, Notification, Subscription, User
|
||||
from files.classes.visstate import StateMod
|
||||
from files.helpers.alerts import NOTIFY_USERS
|
||||
from files.helpers.assetcache import assetcache_path
|
||||
from files.helpers.config.environment import (PUSHER_ID, PUSHER_KEY, SITE_FULL,
|
||||
|
@ -65,7 +66,7 @@ def update_author_comment_count(comment, delta):
|
|||
comment.author.comment_count = g.db.query(Comment).filter(
|
||||
Comment.author_id == comment.author_id,
|
||||
Comment.parent_submission != None,
|
||||
Comment.is_banned == False,
|
||||
Comment.state_mod == StateMod.VISIBLE,
|
||||
Comment.state_user_deleted_utc == None,
|
||||
).count()
|
||||
g.db.add(comment.author)
|
||||
|
@ -218,7 +219,7 @@ def comment_on_publish(comment:Comment):
|
|||
def comment_on_unpublish(comment:Comment):
|
||||
"""
|
||||
Run when a comment becomes invisible: when a moderator makes the comment non-visible
|
||||
by changing the filter_state to "removed", or when the user deletes the comment.
|
||||
by changing the state_mod to "removed", or when the user deletes the comment.
|
||||
Should be used to update stateful counters, notifications, etc. that
|
||||
reflect the comments users will actually see.
|
||||
"""
|
||||
|
@ -231,8 +232,7 @@ def comment_filter_moderated(q: Query, v: Optional[User]) -> Query:
|
|||
.filter(User.shadowbanned == None)
|
||||
if not v or v.admin_level < 2:
|
||||
q = q.filter(
|
||||
((Comment.filter_state != 'filtered')
|
||||
& (Comment.filter_state != 'removed'))
|
||||
(Comment.state_mod == StateMod.VISIBLE)
|
||||
| (Comment.author_id == ((v and v.id) or 0))
|
||||
)
|
||||
return q
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue