Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Send ban messages when the ban is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaCole committed Oct 1, 2015
1 parent 0d412f4 commit 24681c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 6 additions & 7 deletions r2/r2/controllers/api.py
Expand Up @@ -1163,13 +1163,12 @@ def POST_friend(self, form, jquery, friend,
table.insert_table_rows(user_row, index=index)
table.find(".notfound").hide()

if new:
if type == "banned":
if friend.has_interacted_with(container):
send_ban_message(container, c.user, friend,
ban_message, duration)
else:
notify_user_added(type, c.user, friend, container)
if type == "banned":
if friend.has_interacted_with(container):
send_ban_message(container, c.user, friend,
ban_message, duration, new)
elif new:
notify_user_added(type, c.user, friend, container)

@validatedForm(VGold(),
VModhash(),
Expand Down
6 changes: 5 additions & 1 deletion r2/r2/lib/system_messages.py
Expand Up @@ -108,7 +108,7 @@ def notify_user_added(rel_type, author, user, target):
queries.new_message(item, inbox_rel)


def send_ban_message(subreddit, mod, user, note=None, days=None):
def send_ban_message(subreddit, mod, user, note=None, days=None, new=True):
sr_name = "/r/" + subreddit.name
if days:
subject = "you've been temporarily banned from %(subreddit)s"
Expand All @@ -117,6 +117,10 @@ def send_ban_message(subreddit, mod, user, note=None, days=None):
else:
subject = "you've been banned from %(subreddit)s"
message = "you have been banned from posting to %(subreddit)s."

if not new:
subject = "Your ban from %(subreddit)s has changed"

subject %= {"subreddit": sr_name}
message %= {"subreddit": sr_name, "duration": days}

Expand Down

0 comments on commit 24681c0

Please sign in to comment.