Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added is_friend, is_enemy properties to user account JSON responses.

  • Loading branch information...
commit 63002fe83cb94dad84eeca9a24a4d9c6369a3207 1 parent 77f9c25
@DEADB33F authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 r2/r2/lib/jsontemplates.py
View
7 r2/r2/lib/jsontemplates.py
@@ -236,7 +236,8 @@ class AccountJsonTemplate(IdentityJsonTemplate):
_data_attrs_ = IdentityJsonTemplate.data_attrs(has_mail = "has_mail",
has_mod_mail = "has_mod_mail",
is_mod = "is_mod",
- )
+ is_friend = "is_friend",
+ is_enemy = "is_enemy")
def thing_attr(self, thing, attr):
from r2.models import Subreddit
@@ -250,6 +251,10 @@ def thing_attr(self, thing, attr):
return None
if attr == "is_mod":
return bool(Subreddit.reverse_moderator_ids(thing))
+ if attr == "is_friend":
+ return bool(c.user_is_loggedin and thing._id in c.user.friends)
+ if attr == "is_enemy":
+ return bool(c.user_is_loggedin and thing._id in c.user.enemies)
return ThingJsonTemplate.thing_attr(self, thing, attr)
def raw_data(self, thing):
Please sign in to comment.
Something went wrong with that request. Please try again.