Browse Source

Add "slow reply" mode that can be applied to users

merge-requests/76/merge
Deimos 6 years ago
parent
commit
2b2a5313b8
  1. 6
      tildes/tildes/models/comment/comment.py

6
tildes/tildes/models/comment/comment.py

@ -143,6 +143,7 @@ class Comment(DatabaseModel):
def __acl__(self) -> Sequence[Tuple[str, Any, str]]:
"""Pyramid security ACL."""
# pylint: disable=too-many-branches
acl = []
# nobody has any permissions on deleted comments
@ -186,6 +187,8 @@ class Comment(DatabaseModel):
# reply:
# - removed comments can't be replied to by anyone
# - if the topic is locked, only admins can reply
# - if the user has "comment.reply_slow", they can't reply to comments less
# than 2 hours old
# - otherwise, logged-in users can reply
if self.is_removed:
acl.append((Deny, Everyone, "reply"))
@ -194,6 +197,9 @@ class Comment(DatabaseModel):
acl.append((Allow, "admin", "reply"))
acl.append((Deny, Everyone, "reply"))
if utc_now() - self.created_time < timedelta(hours=2):
acl.append((Deny, "comment.reply_slow", "reply"))
acl.append((Allow, Authenticated, "reply"))
# edit:

Loading…
Cancel
Save