From 5ec4d989088efd5e1175e66bdd85c52c9c24d965 Mon Sep 17 00:00:00 2001 From: MelissaCole Date: Wed, 13 May 2015 13:22:34 -0700 Subject: [PATCH] Hide friend label for anonymous messages People could see who gilded them anonymously by having them as a friend and including a specific note. This removes friend notes from messages that have a display_author. --- r2/r2/models/builder.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/r2/r2/models/builder.py b/r2/r2/models/builder.py index a7fa35a1d..409d0990a 100644 --- a/r2/r2/models/builder.py +++ b/r2/r2/models/builder.py @@ -147,14 +147,20 @@ class Builder(object): try: w.author = authors.get(item.author_id) - if user and item.author_id in user.friends: + author_id = item.author_id + + # if display_author exists, then author_id is unknown to the + # receiver, so don't display friend relationship details + if hasattr(item, 'display_author') and item.display_author: + author_id = item.display_author + if user and author_id in user.friends: # deprecated old way: w.friend = True # new way: label = None if friend_rels: - rel = friend_rels[item.author_id] + rel = friend_rels[author_id] note = getattr(rel, "note", None) if note: label = u"%s (%s)" % (_("friend"),