Merge tag 'v1.6.0rc4' into sync/upstream-1.6.0rc4
Conflicts:
app/javascript/mastodon/features/getting_started/index.js
app/javascript/packs/public.js
app/javascript/styles/components.scss
This commit is contained in:
@@ -8,11 +8,12 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
def call(username, domain, json)
|
||||
return if json['inbox'].blank?
|
||||
|
||||
@json = json
|
||||
@uri = @json['id']
|
||||
@username = username
|
||||
@domain = domain
|
||||
@account = Account.find_by(uri: @uri)
|
||||
@json = json
|
||||
@uri = @json['id']
|
||||
@username = username
|
||||
@domain = domain
|
||||
@account = Account.find_by(uri: @uri)
|
||||
@collections = {}
|
||||
|
||||
create_account if @account.nil?
|
||||
upgrade_account if @account.ostatus?
|
||||
@@ -47,11 +48,14 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
@account.url = url || @uri
|
||||
@account.display_name = @json['name'] || ''
|
||||
@account.note = @json['summary'] || ''
|
||||
@account.avatar_remote_url = image_url('icon')
|
||||
@account.header_remote_url = image_url('image')
|
||||
@account.avatar_remote_url = image_url('icon') unless skip_download?
|
||||
@account.header_remote_url = image_url('image') unless skip_download?
|
||||
@account.public_key = public_key || ''
|
||||
@account.locked = @json['manuallyApprovesFollowers'] || false
|
||||
@account.save!
|
||||
@account.statuses_count = outbox_total_items if outbox_total_items.present?
|
||||
@account.following_count = following_total_items if following_total_items.present?
|
||||
@account.followers_count = followers_total_items if followers_total_items.present?
|
||||
@account.save_with_optional_media!
|
||||
end
|
||||
|
||||
def upgrade_account
|
||||
@@ -88,6 +92,33 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
value['href']
|
||||
end
|
||||
|
||||
def outbox_total_items
|
||||
collection_total_items('outbox')
|
||||
end
|
||||
|
||||
def following_total_items
|
||||
collection_total_items('following')
|
||||
end
|
||||
|
||||
def followers_total_items
|
||||
collection_total_items('followers')
|
||||
end
|
||||
|
||||
def collection_total_items(type)
|
||||
return if @json[type].blank?
|
||||
return @collections[type] if @collections.key?(type)
|
||||
|
||||
collection = fetch_resource(@json[type])
|
||||
|
||||
@collections[type] = collection.is_a?(Hash) && collection['totalItems'].present? && collection['totalItems'].is_a?(Numeric) ? collection['totalItems'] : nil
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError
|
||||
@collections[type] = nil
|
||||
end
|
||||
|
||||
def skip_download?
|
||||
@account.suspended? || domain_block&.reject_media?
|
||||
end
|
||||
|
||||
def auto_suspend?
|
||||
domain_block && domain_block.suspend?
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class FollowService < BaseService
|
||||
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
|
||||
raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account)
|
||||
|
||||
return if source_account.following?(target_account)
|
||||
return if source_account.following?(target_account) || source_account.requested?(target_account)
|
||||
|
||||
if target_account.locked? || target_account.activitypub?
|
||||
request_follow(source_account, target_account)
|
||||
|
||||
@@ -27,9 +27,10 @@ class PostStatusService < BaseService
|
||||
thread: in_reply_to,
|
||||
sensitive: options[:sensitive],
|
||||
spoiler_text: options[:spoiler_text] || '',
|
||||
visibility: options[:visibility],
|
||||
visibility: options[:visibility] || account.user&.setting_default_privacy,
|
||||
language: detect_language_for(text, account),
|
||||
application: options[:application])
|
||||
|
||||
attach_media(status, media)
|
||||
end
|
||||
|
||||
|
||||
@@ -4,16 +4,19 @@ class UnsubscribeService < BaseService
|
||||
def call(account)
|
||||
return if account.hub_url.blank?
|
||||
|
||||
@account = account
|
||||
@response = build_request.perform
|
||||
@account = account
|
||||
|
||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{@response.status}" unless @response.status.success?
|
||||
begin
|
||||
@response = build_request.perform
|
||||
|
||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{@response.status}" unless @response.status.success?
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError => e
|
||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{e}"
|
||||
end
|
||||
|
||||
@account.secret = ''
|
||||
@account.subscription_expires_at = nil
|
||||
@account.save!
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError
|
||||
Rails.logger.debug "PuSH subscription request for #{@account.acct} could not be made due to HTTP or SSL error"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user