about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-12 04:38:56 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-12 04:38:56 -0600
commita8713ee8b73ef63dab45c3c4db949dbfc49a6381 (patch)
tree51bc07def409119d246bbbcf4e123ebc0572470a /app/models
parent90373b7f3190e86882e764d9cf595f7345a97245 (diff)
add ability for post authors to kick jerks out of their threads
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