diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index 1419571c7..1a260bb65 100644 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -629,6 +629,8 @@ class MessageController(ListingController): # TODO: Consider a flag to disable this (and see above plus builder.py) if (item._deleted or item._spam) and not c.user_is_admin: return False + if item.author_id in c.user.enemies: + return False # don't show user their own unread stuff if ((self.where == 'unread' or self.subwhere == 'unread') and (item.author_id == c.user._id or not item.new)): diff --git a/r2/r2/models/account.py b/r2/r2/models/account.py index 1aee87bed..99297870b 100644 --- a/r2/r2/models/account.py +++ b/r2/r2/models/account.py @@ -655,12 +655,3 @@ class DeletedUser(FakeAccount): pass else: object.__setattr__(self, attr, val) - -class BlockedUser(DeletedUser): - @property - def name(self): - return '[blocked]' - - @property - def _deleted(self): - return False diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index fc6c35009..12c528deb 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -24,7 +24,7 @@ from r2.lib.db.thing import Thing, Relation, NotFound, MultiRelation, \ from r2.lib.db.operators import desc from r2.lib.utils import base_url, tup, domain, title_to_url, UrlParser from r2.lib.utils.trial_utils import trial_info -from account import Account, DeletedUser, BlockedUser +from account import Account, DeletedUser from subreddit import Subreddit from printable import Printable from r2.config import cache @@ -1105,12 +1105,11 @@ class Message(Thing, Printable): item.is_collapsed = item.author_collapse if c.user.pref_collapse_read_messages: item.is_collapsed = (item.is_collapsed is not False) - if item.author_id in c.user.enemies: + if item.author_id in c.user.enemies and not item.was_comment: item.is_collapsed = True if not c.user_is_admin: - item.author = BlockedUser() - item.subject = _('[blocked]') - item.body = _('[blocked]') + item.subject = _('[message from blocked user]') + item.body = _('[unblock user to see this message]') # Run this last diff --git a/r2/r2/templates/wrappeduser.html b/r2/r2/templates/wrappeduser.html index 618b3edf6..6b797593e 100644 --- a/r2/r2/templates/wrappeduser.html +++ b/r2/r2/templates/wrappeduser.html @@ -28,7 +28,7 @@ %if thing.user_deleted: [deleted] %elif thing.name == '[blocked]': - ${_(thing.name)} + ${_(thing.thing.original_author.name)} %else: ${plain_link(thing.name + thing.karma, "/user/%s" % thing.name, _class = thing.author_cls + (" id-%s" % thing.fullname),