Fix error handling for removing subscriptions.

(imported from commit b95a706ed9499e96c4ff27ca583ed10dab674736)
This commit is contained in:
Tim Abbott 2012-10-20 17:05:13 -04:00
parent a8e4c818c6
commit 1fcb4c0576
1 changed files with 3 additions and 1 deletions

View File

@ -537,8 +537,10 @@ def json_remove_subscription(request):
sub_name = request.POST.get('subscription')
stream = get_stream(sub_name, user_profile.realm)
if not stream:
return json_error("Stream does not exist")
did_remove = do_remove_subscription(user_profile, stream)
if not did_remove:
return json_error("Not subscribed, so you can't unsubscribe")
do_remove_subscription(user_profile, stream)
return json_success({"data": sub_name})