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/concerns/account_associations.rb3
-rw-r--r--app/models/concerns/status_threading_concern.rb3
-rw-r--r--app/models/conversation.rb1
-rw-r--r--app/models/conversation_kick.rb13
4 files changed, 19 insertions, 1 deletions
diff --git a/app/models/concerns/account_associations.rb b/app/models/concerns/account_associations.rb
index a90104943..19190f0c5 100644
--- a/app/models/concerns/account_associations.rb
+++ b/app/models/concerns/account_associations.rb
@@ -61,5 +61,8 @@ module AccountAssociations
 
     # queued boosts
     has_many :queued_boosts, dependent: :destroy, inverse_of: :account
+
+    # kicked-out-of conversations
+    has_many :conversation_kicks, dependent: :destroy, inverse_of: :account
   end
 end
diff --git a/app/models/concerns/status_threading_concern.rb b/app/models/concerns/status_threading_concern.rb
index 1e5c52c46..adf8659d3 100644
--- a/app/models/concerns/status_threading_concern.rb
+++ b/app/models/concerns/status_threading_concern.rb
@@ -127,7 +127,8 @@ module StatusThreadingConcern
   end
 
   def statuses_with_accounts(ids)
-    Status.where(id: ids).includes(:account)
+    kicked_accounts = ConversationKick.select(:account_id).where(conversation_id: self.conversation_id)
+    Status.where(id: ids).where.not(account_id: kicked_accounts).includes(:account)
   end
 
   def filter_from_context?(status, account, relations)
diff --git a/app/models/conversation.rb b/app/models/conversation.rb
index 4dfaea889..7d277fa85 100644
--- a/app/models/conversation.rb
+++ b/app/models/conversation.rb
@@ -13,6 +13,7 @@ class Conversation < ApplicationRecord
   validates :uri, uniqueness: true, if: :uri?
 
   has_many :statuses
+  has_many :kicks, class_name: 'ConversationKick', inverse_of: :conversation, dependent: :destroy
 
   def local?
     uri.nil?
diff --git a/app/models/conversation_kick.rb b/app/models/conversation_kick.rb
new file mode 100644
index 000000000..c2dbdf50b
--- /dev/null
+++ b/app/models/conversation_kick.rb
@@ -0,0 +1,13 @@
+# == Schema Information
+#
+# Table name: conversation_kicks
+#
+#  id              :bigint(8)        not null, primary key
+#  account_id      :bigint(8)        not null
+#  conversation_id :bigint(8)        not null
+#
+
+class ConversationKick < ApplicationRecord
+  belongs_to :account
+  belongs_to :conversation
+end