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/block.rb17
-rw-r--r--app/models/favourite.rb21
-rw-r--r--app/models/follow.rb13
-rw-r--r--app/models/follow_request.rb42
-rw-r--r--app/models/stream_entry.rb8
5 files changed, 2 insertions, 99 deletions
diff --git a/app/models/block.rb b/app/models/block.rb
index d0662b685..9c55703c9 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -2,27 +2,10 @@
 
 class Block < ApplicationRecord
   include Paginable
-  include Streamable
 
   belongs_to :account
   belongs_to :target_account, class_name: 'Account'
 
   validates :account, :target_account, presence: true
   validates :account_id, uniqueness: { scope: :target_account_id }
-
-  def verb
-    destroyed? ? :unblock : :block
-  end
-
-  def target
-    target_account
-  end
-
-  def hidden?
-    true
-  end
-
-  def title
-    destroyed? ? "#{account.acct} is no longer blocking #{target_account.acct}" : "#{account.acct} blocked #{target_account.acct}"
-  end
 end
diff --git a/app/models/favourite.rb b/app/models/favourite.rb
index 82f8c5258..67a293888 100644
--- a/app/models/favourite.rb
+++ b/app/models/favourite.rb
@@ -2,7 +2,6 @@
 
 class Favourite < ApplicationRecord
   include Paginable
-  include Streamable
 
   belongs_to :account, inverse_of: :favourites
   belongs_to :status,  inverse_of: :favourites
@@ -11,26 +10,6 @@ class Favourite < ApplicationRecord
 
   validates :status_id, uniqueness: { scope: :account_id }
 
-  def verb
-    destroyed? ? :unfavorite : :favorite
-  end
-
-  def title
-    destroyed? ? "#{account.acct} no longer favourites a status by #{status.account.acct}" : "#{account.acct} favourited a status by #{status.account.acct}"
-  end
-
-  def thread
-    status
-  end
-
-  def target
-    thread
-  end
-
-  def hidden?
-    status.private_visibility?
-  end
-
   before_validation do
     self.status = status.reblog if status.reblog?
   end
diff --git a/app/models/follow.rb b/app/models/follow.rb
index e25c2bc9f..57db8c462 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -2,7 +2,6 @@
 
 class Follow < ApplicationRecord
   include Paginable
-  include Streamable
 
   belongs_to :account
   belongs_to :target_account, class_name: 'Account'
@@ -11,16 +10,4 @@ class Follow < ApplicationRecord
 
   validates :account, :target_account, presence: true
   validates :account_id, uniqueness: { scope: :target_account_id }
-
-  def verb
-    destroyed? ? :unfollow : :follow
-  end
-
-  def target
-    target_account
-  end
-
-  def title
-    destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}"
-  end
 end
diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb
index 2755ba0ab..4224ab15d 100644
--- a/app/models/follow_request.rb
+++ b/app/models/follow_request.rb
@@ -2,7 +2,6 @@
 
 class FollowRequest < ApplicationRecord
   include Paginable
-  include Streamable
 
   belongs_to :account
   belongs_to :target_account, class_name: 'Account'
@@ -13,9 +12,6 @@ class FollowRequest < ApplicationRecord
   validates :account_id, uniqueness: { scope: :target_account_id }
 
   def authorize!
-    @verb   = :authorize
-    @target = clone.freeze
-
     account.follow!(target_account)
     MergeWorker.perform_async(target_account.id, account.id)
 
@@ -23,44 +19,6 @@ class FollowRequest < ApplicationRecord
   end
 
   def reject!
-    @verb   = :reject
-    @target = clone.freeze
-
     destroy!
   end
-
-  def verb
-    destroyed? ? (@verb || :delete) : :request_friend
-  end
-
-  def target
-    if destroyed? && @verb
-      @target
-    else
-      target_account
-    end
-  end
-
-  def hidden?
-    true
-  end
-
-  def needs_stream_entry?
-    true
-  end
-
-  def title
-    if destroyed?
-      case @verb
-      when :authorize
-        "#{target_account.acct} authorized #{account.acct}'s request to follow"
-      when :reject
-        "#{target_account.acct} rejected #{account.acct}'s request to follow"
-      else
-        "#{account.acct} withdrew the request to follow #{target_account.acct}"
-      end
-    else
-      "#{account.acct} requested to follow #{target_account.acct}"
-    end
-  end
 end
diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb
index bb68b1e14..8b41c8c39 100644
--- a/app/models/stream_entry.rb
+++ b/app/models/stream_entry.rb
@@ -6,17 +6,13 @@ class StreamEntry < ApplicationRecord
   belongs_to :account, inverse_of: :stream_entries
   belongs_to :activity, polymorphic: true
 
-  belongs_to :status,         foreign_type: 'Status',        foreign_key: 'activity_id'
-  belongs_to :follow,         foreign_type: 'Follow',        foreign_key: 'activity_id'
-  belongs_to :favourite,      foreign_type: 'Favourite',     foreign_key: 'activity_id'
-  belongs_to :block,          foreign_type: 'Block',         foreign_key: 'activity_id'
-  belongs_to :follow_request, foreign_type: 'FollowRequest', foreign_key: 'activity_id'
+  belongs_to :status, foreign_type: 'Status', foreign_key: 'activity_id', inverse_of: :stream_entry
 
   validates :account, :activity, presence: true
 
   STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, mentions: :account], thread: [:stream_entry, :account]].freeze
 
-  scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES, favourite: [:account, :stream_entry, status: STATUS_INCLUDES], follow: [:target_account, :stream_entry]) }
+  scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) }
 
   def object_type
     if orphaned?