From fcedf701ee1587e4de153b983ae9cca5ea5d7451 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 16 Jan 2013 14:16:58 -0800 Subject: [PATCH] Make API banned_by / approved_by mutually exclusive. This also fixes an API bug where banned_by was always true if you don't have moderator permission for a thing. --- r2/r2/lib/jsontemplates.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index a5a088ebf..b3698a02c 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -191,9 +191,12 @@ class ThingJsonTemplate(JsonTemplate): return thing.reported ban_info = getattr(thing, "ban_info", {}) if attr == "banned_by": - return ban_info.get("banner") if ban_info.get('moderator_banned') else True + banner = (ban_info.get("banner") + if ban_info.get('moderator_banned') + else True) + return banner if thing._spam else None elif attr == "approved_by": - return ban_info.get("unbanner") + return ban_info.get("unbanner") if not thing._spam else None return getattr(thing, attr, None)