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:
Eugen Rochko
2016-12-22 23:03:57 +01:00
parent 2d2154ba75
commit b891a81008
24 changed files with 145 additions and 47 deletions

View File

@ -10,6 +10,20 @@ class FollowService < BaseService
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
raise Mastodon::NotPermitted if target_account.blocking?(source_account)
if target_account.locked?
request_follow(source_account, target_account)
else
direct_follow(source_account, target_account)
end
end
private
def request_follow(source_account, target_account)
FollowRequest.create!(account: source_account, target_account: target_account)
end
def direct_follow(source_account, target_account)
follow = source_account.follow!(target_account)
if target_account.local?
@ -19,25 +33,12 @@ class FollowService < BaseService
NotificationWorker.perform_async(follow.stream_entry.id, target_account.id)
end
merge_into_timeline(target_account, source_account)
FeedManager.instance.merge_into_timeline(target_account, source_account)
Pubsubhubbub::DistributionWorker.perform_async(follow.stream_entry.id)
follow
end
private
def merge_into_timeline(from_account, into_account)
timeline_key = FeedManager.instance.key(:home, into_account.id)
from_account.statuses.find_each do |status|
redis.zadd(timeline_key, status.id, status.id)
end
FeedManager.instance.trim(:home, into_account.id)
end
def redis
Redis.current
end