about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/direct_feed.rb9
-rw-r--r--app/models/status.rb19
-rw-r--r--app/models/user.rb1
3 files changed, 12 insertions, 17 deletions
diff --git a/app/models/direct_feed.rb b/app/models/direct_feed.rb
index 1f2448070..689a735b3 100644
--- a/app/models/direct_feed.rb
+++ b/app/models/direct_feed.rb
@@ -4,9 +4,8 @@ class DirectFeed < Feed
   include Redisable
 
   def initialize(account)
-    @type    = :direct
-    @id      = account.id
     @account = account
+    super(:direct, account.id)
   end
 
   def get(limit, max_id = nil, since_id = nil, min_id = nil)
@@ -19,10 +18,12 @@ class DirectFeed < Feed
 
   private
 
-  def from_database(limit, max_id, since_id, min_id)
+  # TODO: _min_id is not actually handled by `as_direct_timeline`
+  def from_database(limit, max_id, since_id, _min_id)
     loop do
-      statuses = Status.as_direct_timeline(@account, limit, max_id, since_id, min_id)
+      statuses = Status.as_direct_timeline(@account, limit, max_id, since_id)
       return statuses if statuses.empty?
+
       max_id = statuses.last.id
       statuses = statuses.reject { |status| FeedManager.instance.filter?(:direct, status, @account) }
       return statuses unless statuses.empty?
diff --git a/app/models/status.rb b/app/models/status.rb
index e01ddb5c5..8a58e5d68 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -338,7 +338,7 @@ class Status < ApplicationRecord
       visibilities.keys - %w(direct limited)
     end
 
-    def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false)
+    def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil)
       # direct timeline is mix of direct message from_me and to_me.
       # 2 queries are executed with pagination.
       # constant expression using arel_table is required for partial index
@@ -369,14 +369,9 @@ class Status < ApplicationRecord
         query_to_me = query_to_me.where('mentions.status_id > ?', since_id)
       end
 
-      if cache_ids
-        # returns array of cache_ids object that have id and updated_at
-        (query_from_me.cache_ids.to_a + query_to_me.cache_ids.to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
-      else
-        # returns ActiveRecord.Relation
-        items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
-        Status.where(id: items.map(&:id))
-      end
+      # returns ActiveRecord.Relation
+      items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
+      Status.where(id: items.map(&:id))
     end
 
     def favourites_map(status_ids, account_id)
@@ -553,9 +548,9 @@ class Status < ApplicationRecord
   end
 
   def set_locality
-    if account.domain.nil? && !attribute_changed?(:local_only)
-      self.local_only = marked_local_only?
-    end
+    return unless account.domain.nil? && !attribute_changed?(:local_only)
+
+    self.local_only = marked_local_only?
   end
 
   def set_conversation
diff --git a/app/models/user.rb b/app/models/user.rb
index 3471bb2c1..daf8768e8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -244,7 +244,6 @@ class User < ApplicationRecord
   end
 
   def functional?
-
     functional_or_moved?
   end