about summary refs log tree commit diff
path: root/app/views
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-03 14:50:22 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-03 14:50:22 +0100
commite4671adc25081161268c885b3427fd84cbecb249 (patch)
tree0bd6e1cdbdad43225574a64a712e2fe0bc4f1817 /app/views
parentc003e7075880071743af06cfb5865bdb943db024 (diff)
Fix reblogged/favourited caching; add API endpoints for who favd/reblogged status
Diffstat (limited to 'app/views')
-rw-r--r--app/views/api/v1/statuses/_show.rabl3
-rw-r--r--app/views/api/v1/statuses/accounts.rabl2
-rw-r--r--app/views/api/v1/statuses/show.rabl7
3 files changed, 9 insertions, 3 deletions
diff --git a/app/views/api/v1/statuses/_show.rabl b/app/views/api/v1/statuses/_show.rabl
index 8e7cd97ee..b105a114b 100644
--- a/app/views/api/v1/statuses/_show.rabl
+++ b/app/views/api/v1/statuses/_show.rabl
@@ -1,3 +1,4 @@
+cache
 attributes :id, :created_at, :in_reply_to_id
 
 node(:uri)              { |status| TagManager.instance.uri_for(status) }
@@ -5,8 +6,6 @@ node(:content)          { |status| Formatter.instance.format(status) }
 node(:url)              { |status| TagManager.instance.url_for(status) }
 node(:reblogs_count)    { |status| status.reblogs_count }
 node(:favourites_count) { |status| status.favourites_count }
-node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? !!@favourites_map[status.id] : current_account.favourited?(status) }
-node(:reblogged,  if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map)    ? !!@reblogs_map[status.id]    : current_account.reblogged?(status) }
 
 child :account do
   extends 'api/v1/accounts/show'
diff --git a/app/views/api/v1/statuses/accounts.rabl b/app/views/api/v1/statuses/accounts.rabl
new file mode 100644
index 000000000..9f3b13a53
--- /dev/null
+++ b/app/views/api/v1/statuses/accounts.rabl
@@ -0,0 +1,2 @@
+collection @accounts
+extends 'api/v1/accounts/show'
diff --git a/app/views/api/v1/statuses/show.rabl b/app/views/api/v1/statuses/show.rabl
index 1c586a3a5..1b4651cdd 100644
--- a/app/views/api/v1/statuses/show.rabl
+++ b/app/views/api/v1/statuses/show.rabl
@@ -1,8 +1,13 @@
 object @status
-cache
 
 extends 'api/v1/statuses/_show'
 
+node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? !!@favourites_map[status.id] : current_account.favourited?(status) }
+node(:reblogged,  if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map)    ? !!@reblogs_map[status.id]    : current_account.reblogged?(status) }
+
 child :reblog => :reblog do
   extends 'api/v1/statuses/_show'
+
+  node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? !!@favourites_map[status.id] : current_account.favourited?(status) }
+  node(:reblogged,  if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map)    ? !!@reblogs_map[status.id]    : current_account.reblogged?(status) }
 end