about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorKaito Sinclaire <MattWCSTRFAN@gmail.com>2018-04-18 04:09:06 -0700
committerEugen Rochko <eugen@zeonfederated.com>2018-04-18 13:09:06 +0200
commit156b916caf4ec902a8db525843e95c1a42350207 (patch)
tree3f80c7da4842fc87bb56e62f5258072693fe415f /app/models
parentaedfea3554dc5cd60f4bebd828109d1ef4327814 (diff)
Direct messages column (#4514)
* Added a timeline for Direct statuses
* Lists all Direct statuses you've sent and received
* Displayed in Getting Started
* Streaming server support for direct TL

* Changes to match other timelines in 2.0
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 f924be47b..62857dd6b 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -183,6 +183,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