Skip to content

Commit

Permalink
Allow employees to distinguish messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjoconnor committed Jun 30, 2016
1 parent e355b0d commit 74033fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions r2/r2/lib/pages/things.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def __init__(self, thing, delete = False, report = True):
can_block = True
can_mute = False
is_admin_message = False
show_distinguish = c.user.employee
del_on_recipient = (isinstance(thing, Message) and
thing.del_on_recipient)

Expand Down Expand Up @@ -325,6 +326,8 @@ def __init__(self, thing, delete = False, report = True):
can_mute = can_mute,
is_admin_message = is_admin_message,
del_on_recipient=del_on_recipient,
show_distinguish=show_distinguish,
distinguished=thing.distinguished,
)


Expand Down
16 changes: 9 additions & 7 deletions r2/r2/lib/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,20 +1205,22 @@ def run(self, thing_name, how):
item = VByName.run(self, thing_name)

if item.author_id == c.user._id:
# will throw a legitimate 500 if this isn't a link or
# comment, because this should only be used on links and
# comments
if isinstance(item, Message) and c.user.employee:
return True
subreddit = item.subreddit_slow

if how in ("yes", "no") and subreddit.can_distinguish(c.user):
if (how in ("yes", "no") and
subreddit.can_distinguish(c.user)):
can_distinguish = True
elif how in ("special", "no") and c.user_special_distinguish:
elif (how in ("special", "no") and
c.user_special_distinguish):
can_distinguish = True
elif how in ("admin", "no") and c.user.employee:
elif (how in ("admin", "no") and
c.user.employee):
can_distinguish = True

if can_distinguish:
# Don't allow distinguishing for users who are in timeout
# Don't allow distinguishing for users in timeout
VNotInTimeout().run(target=item, subreddit=subreddit)
return can_distinguish

Expand Down
1 change: 1 addition & 0 deletions r2/r2/templates/printablebuttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<li class="first">
${self.bylink_button(_("permalink"), thing.permalink, sr_path=False, event_action="permalink")}
</li>
${self.distinguish()}
%endif
%if thing.user_is_recipient:
## only allow message deleting on recipient side now
Expand Down

0 comments on commit 74033fc

Please sign in to comment.