about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorbeatrix <beatrix.bitrot@gmail.com>2017-10-25 17:37:06 -0400
committerGitHub <noreply@github.com>2017-10-25 17:37:06 -0400
commit31814ddda009939d5d2ebe3e0ac061c26387529a (patch)
tree19e002405d30a50aca740a979efeb6b3a9d1e186 /app/models
parent5f0268ab842990740d79d44e77159bb52f1a08ce (diff)
parent42f2045c217df4b482e6ce70615a1d3252e0e972 (diff)
Merge pull request #198 from glitch-soc/gs-direct-timeline
Direct messages timeline from tootsuite/mastodon#4514
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 30d53f298..d78a921b5 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -154,6 +154,14 @@ class Status < ApplicationRecord
       where(account: [account] + account.following).where(visibility: [:public, :unlisted, :private])
     end
 
+    def as_direct_timeline(account)
+      query = joins("LEFT OUTER JOIN mentions ON statuses.id = mentions.status_id AND mentions.account_id = #{account.id}")
+              .where("mentions.account_id = #{account.id} OR statuses.account_id = #{account.id}")
+              .where(visibility: [:direct])
+
+      apply_timeline_filters(query, account, false)
+    end
+
     def as_public_timeline(account = nil, local_only = false)
       query = timeline_scope(local_only).without_replies