about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/api/v1/timelines/tag_controller.rb14
-rw-r--r--db/migrate/20190805064643_create_bookmark_tags.rb5
2 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/api/v1/timelines/tag_controller.rb b/app/controllers/api/v1/timelines/tag_controller.rb
index 9adc4ad29..a0a10d349 100644
--- a/app/controllers/api/v1/timelines/tag_controller.rb
+++ b/app/controllers/api/v1/timelines/tag_controller.rb
@@ -28,6 +28,8 @@ class Api::V1::Timelines::TagController < Api::BaseController
   def tagged_statuses
     if @tag.nil?
       []
+    elsif @tag.name.in?(['self.bookmarks', '.self.bookmarks'])
+      Status.reorder(nil).joins(:bookmarks).merge(bookmark_results)
     else
       statuses = tag_timeline_statuses.paginate_by_id(
         limit_param(DEFAULT_STATUSES_LIMIT),
@@ -48,6 +50,18 @@ class Api::V1::Timelines::TagController < Api::BaseController
     HashtagQueryService.new.call(@tag, params.slice(:any, :all, :none), current_account, truthy_param?(:local))
   end
 
+  def bookmark_results
+    @_results ||= account_bookmarks.paginate_by_max_id(
+      limit_param(DEFAULT_STATUSES_LIMIT),
+      params[:max_id],
+      params[:since_id]
+    )
+  end
+
+  def account_bookmarks
+    current_account.bookmarks
+  end
+
   def insert_pagination_headers
     set_pagination_headers(next_path, prev_path)
   end
diff --git a/db/migrate/20190805064643_create_bookmark_tags.rb b/db/migrate/20190805064643_create_bookmark_tags.rb
new file mode 100644
index 000000000..b21029581
--- /dev/null
+++ b/db/migrate/20190805064643_create_bookmark_tags.rb
@@ -0,0 +1,5 @@
+class CreateBookmarkTags < ActiveRecord::Migration[5.2]
+  def up
+    %w(self.bookmarks .self.bookmarks).each { |name| Tag.find_or_create_by(name: name) }
+  end
+end