diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-22 23:03:57 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-22 23:03:57 +0100 |
commit | b891a81008d2cf595cb37432a8e1f36606db16d6 (patch) | |
tree | e3b083966fc14dda46a2ec75586fdf566c2585aa /app/services | |
parent | 2d2154ba75279186b064c887452b7d6ee70b8ba2 (diff) |
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
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/follow_service.rb | 29 | ||||
-rw-r--r-- | app/services/reblog_service.rb | 2 |
2 files changed, 16 insertions, 15 deletions
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 02baa6553..a73ec344d 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -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 diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 1a78b8f69..23b35ffd2 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -6,7 +6,7 @@ class ReblogService < BaseService # @param [Status] reblogged_status Status to be reblogged # @return [Status] def call(account, reblogged_status) - raise ActiveRecord::RecordInvalid if reblogged_status.private_visibility? + raise Mastodon::NotPermitted if reblogged_status.private_visibility? reblog = account.statuses.create!(reblog: reblogged_status, text: '') |