diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-12-21 15:24:34 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-12-21 15:25:32 -0600 |
commit | 806199ed4ae23fd165397b41405523e672c7e090 (patch) | |
tree | 3b224576fcea701a35b18449a5e2cedd5f0ca01d /app | |
parent | 5f92c6429fac98e5c9e3b02d158b6d4eab89945d (diff) |
add virtual scopes for `#``self.boosts` (your boosts) & `#``self.home.boosts` (boosts on your home timeline)
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/v1/timelines/tag_controller.rb | 30 | ||||
-rw-r--r-- | app/models/status.rb | 5 |
2 files changed, 32 insertions, 3 deletions
diff --git a/app/controllers/api/v1/timelines/tag_controller.rb b/app/controllers/api/v1/timelines/tag_controller.rb index 8316d8a9f..7e60e422b 100644 --- a/app/controllers/api/v1/timelines/tag_controller.rb +++ b/app/controllers/api/v1/timelines/tag_controller.rb @@ -30,6 +30,10 @@ class Api::V1::Timelines::TagController < Api::BaseController [] elsif @tag.name.in?(['self.bookmarks', '.self.bookmarks']) Status.reorder(nil).joins(:bookmarks).merge(bookmark_results) + elsif @tag.name.in?(['self.boosts', '.self.boosts']) + reblog_results + elsif @tag.name.in?(['self.home.boosts', '.self.home.boosts']) + home_reblog_results else statuses = tag_timeline_statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), @@ -51,7 +55,7 @@ class Api::V1::Timelines::TagController < Api::BaseController end def bookmark_results - @_results ||= account_bookmarks.paginate_by_max_id( + account_bookmarks.paginate_by_max_id( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id] @@ -62,6 +66,30 @@ class Api::V1::Timelines::TagController < Api::BaseController current_account.bookmarks end + def reblog_results + account_reblogs.paginate_by_max_id( + limit_param(DEFAULT_STATUSES_LIMIT), + params[:max_id], + params[:since_id] + ) + end + + def account_reblogs + current_account.statuses.reblogs + end + + def home_reblog_results + account_home_reblogs.paginate_by_max_id( + limit_param(DEFAULT_STATUSES_LIMIT), + params[:max_id], + params[:since_id] + ) + end + + def account_home_reblogs + Status.as_home_timeline(current_account, reblogs_only: true) + end + def insert_pagination_headers set_pagination_headers(next_path, prev_path) end diff --git a/app/models/status.rb b/app/models/status.rb index a47f846a5..f4c90fea2 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -391,9 +391,10 @@ class Status < ApplicationRecord where(language: nil).or where(language: account.chosen_languages) end - def as_home_timeline(account) + def as_home_timeline(account, reblogs_only: false) query = where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private]) - query = query.without_reblogs if account.present? && account&.user&.hide_boosts + query = query.without_reblogs if !reblogs_only && account.present? && account&.user&.hide_boosts + query = query.reblogs if reblogs_only query end |