Follow call on locked account creates follow request instead
Reflect "requested" relationship in API and UI Reflect inability of private posts to be reblogged in the UI Disable Webfinger for locked accounts
This commit is contained in:
parent
2d2154ba75
commit
b891a81008
24 changed files with 145 additions and 47 deletions
|
@ -34,6 +34,8 @@ class Account < ApplicationRecord
|
|||
has_many :notifications, inverse_of: :account, dependent: :destroy
|
||||
|
||||
# Follow relations
|
||||
has_many :follow_requests, dependent: :destroy
|
||||
|
||||
has_many :active_relationships, class_name: 'Follow', foreign_key: 'account_id', dependent: :destroy
|
||||
has_many :passive_relationships, class_name: 'Follow', foreign_key: 'target_account_id', dependent: :destroy
|
||||
|
||||
|
@ -179,6 +181,10 @@ class Account < ApplicationRecord
|
|||
def blocking_map(target_account_ids, account_id)
|
||||
Block.where(target_account_id: target_account_ids).where(account_id: account_id).map { |b| [b.target_account_id, true] }.to_h
|
||||
end
|
||||
|
||||
def requested_map(target_account_ids, account_id)
|
||||
FollowRequest.where(target_account_id: target_account_ids).where(account_id: account_id).map { |r| [r.target_account_id, true] }.to_h
|
||||
end
|
||||
end
|
||||
|
||||
before_create do
|
||||
|
|
19
app/models/follow_request.rb
Normal file
19
app/models/follow_request.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FollowRequest < ApplicationRecord
|
||||
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 authorize!
|
||||
account.follow!(target_account)
|
||||
FeedManager.instance.merge_into_timeline(target_account, account)
|
||||
destroy!
|
||||
end
|
||||
|
||||
def reject!
|
||||
destroy!
|
||||
end
|
||||
end
|
|
@ -170,7 +170,7 @@ class Status < ApplicationRecord
|
|||
text.strip!
|
||||
self.reblog = reblog.reblog if reblog? && reblog.reblog?
|
||||
self.in_reply_to_account_id = thread.account_id if reply?
|
||||
self.visibility = :public if visibility.nil?
|
||||
self.visibility = (account.locked? ? :private : :public) if visibility.nil?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue