Fix semantics of follow requests another slaps
This commit is contained in:
		@@ -191,6 +191,7 @@ module AtomBuilderHelper
 | 
			
		||||
          include_author xml, stream_entry.target
 | 
			
		||||
        else
 | 
			
		||||
          object_type    xml, stream_entry.target.object_type
 | 
			
		||||
          verb           xml, stream_entry.target.verb
 | 
			
		||||
          title          xml, stream_entry.target.title
 | 
			
		||||
          link_alternate xml, TagManager.instance.url_for(stream_entry.target)
 | 
			
		||||
        end
 | 
			
		||||
 
 | 
			
		||||
@@ -18,10 +18,6 @@ class Block < ApplicationRecord
 | 
			
		||||
    target_account
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def object_type
 | 
			
		||||
    :person
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def hidden?
 | 
			
		||||
    true
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -19,8 +19,6 @@ class Favourite < ApplicationRecord
 | 
			
		||||
    destroyed? ? "#{account.acct} no longer favourites a status by #{status.account.acct}" : "#{account.acct} favourited a status by #{status.account.acct}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  delegate :object_type, to: :target
 | 
			
		||||
 | 
			
		||||
  def thread
 | 
			
		||||
    status
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -20,10 +20,6 @@ class Follow < ApplicationRecord
 | 
			
		||||
    target_account
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def object_type
 | 
			
		||||
    :person
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def title
 | 
			
		||||
    destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}"
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,8 @@ class FollowRequest < ApplicationRecord
 | 
			
		||||
  validates :account_id, uniqueness: { scope: :target_account_id }
 | 
			
		||||
 | 
			
		||||
  def authorize!
 | 
			
		||||
    @verb = :authorize
 | 
			
		||||
    @verb   = :authorize
 | 
			
		||||
    @target = clone.freeze
 | 
			
		||||
 | 
			
		||||
    account.follow!(target_account)
 | 
			
		||||
    MergeWorker.perform_async(target_account.id, account.id)
 | 
			
		||||
@@ -22,7 +23,9 @@ class FollowRequest < ApplicationRecord
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def reject!
 | 
			
		||||
    @verb = :reject
 | 
			
		||||
    @verb   = :reject
 | 
			
		||||
    @target = clone.freeze
 | 
			
		||||
 | 
			
		||||
    destroy!
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -31,11 +34,11 @@ class FollowRequest < ApplicationRecord
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def target
 | 
			
		||||
    target_account
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def object_type
 | 
			
		||||
    :person
 | 
			
		||||
    if destroyed? && @verb
 | 
			
		||||
      @target
 | 
			
		||||
    else
 | 
			
		||||
      target_account
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def hidden?
 | 
			
		||||
 
 | 
			
		||||
@@ -6,10 +6,11 @@ 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 :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'
 | 
			
		||||
 | 
			
		||||
  validates :account, :activity, presence: true
 | 
			
		||||
 | 
			
		||||
@@ -30,7 +31,7 @@ class StreamEntry < ApplicationRecord
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def targeted?
 | 
			
		||||
    [:follow, :request_friend, :authorize, :unfollow, :block, :unblock, :share, :favorite].include? verb
 | 
			
		||||
    [:follow, :request_friend, :authorize, :reject, :unfollow, :block, :unblock, :share, :favorite].include? verb
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def target
 | 
			
		||||
@@ -58,7 +59,7 @@ class StreamEntry < ApplicationRecord
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def activity
 | 
			
		||||
    !new_record? ? send(activity_type.downcase) : super
 | 
			
		||||
    !new_record? ? send(activity_type.underscore) : super
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user