Merge branch 'master' into glitch-soc/master
Conflicts: app/models/account.rb app/views/accounts/_header.html.haml
This commit is contained in:
@@ -34,6 +34,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
||||
end
|
||||
|
||||
def trustworthy_attribution?(uri, attributed_to)
|
||||
return false if uri.nil? || attributed_to.nil?
|
||||
Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero?
|
||||
end
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
@account.note = @json['summary'] || ''
|
||||
@account.locked = @json['manuallyApprovesFollowers'] || false
|
||||
@account.fields = property_values || {}
|
||||
@account.actor_type = actor_type
|
||||
end
|
||||
|
||||
def set_fetchable_attributes!
|
||||
@@ -95,6 +96,14 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id)
|
||||
end
|
||||
|
||||
def actor_type
|
||||
if @json['type'].is_a?(Array)
|
||||
@json['type'].find { |type| ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(type) }
|
||||
else
|
||||
@json['type']
|
||||
end
|
||||
end
|
||||
|
||||
def image_url(key)
|
||||
value = first_of_value(@json[key])
|
||||
|
||||
|
||||
@@ -45,5 +45,8 @@ class ActivityPub::ProcessCollectionService < BaseService
|
||||
|
||||
def verify_account!
|
||||
@account = ActivityPub::LinkedDataSignature.new(@json).verify_account!
|
||||
rescue JSON::LD::JsonLdError => e
|
||||
Rails.logger.debug "Could not verify LD-Signature for #{value_or_id(@json['actor'])}: #{e.message}"
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ class FanOutOnWriteService < BaseService
|
||||
def deliver_to_followers(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to followers"
|
||||
|
||||
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).reorder(nil).find_in_batches do |followers|
|
||||
status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago).select(:id).reorder(nil).find_in_batches do |followers|
|
||||
FeedInsertWorker.push_bulk(followers) do |follower|
|
||||
[status.id, follower.id, :home]
|
||||
end
|
||||
@@ -47,7 +47,7 @@ class FanOutOnWriteService < BaseService
|
||||
def deliver_to_lists(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to lists"
|
||||
|
||||
status.account.lists.joins(account: :user).where('users.current_sign_in_at > ?', 14.days.ago).select(:id).reorder(nil).find_in_batches do |lists|
|
||||
status.account.lists.joins(account: :user).where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago).select(:id).reorder(nil).find_in_batches do |lists|
|
||||
FeedInsertWorker.push_bulk(lists) do |list|
|
||||
[status.id, list.id, :list]
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class FetchLinkCardService < BaseService
|
||||
end
|
||||
|
||||
attach_card if @card&.persisted?
|
||||
rescue HTTP::Error, Addressable::URI::InvalidURIError => e
|
||||
rescue HTTP::Error, Addressable::URI::InvalidURIError, Mastodon::LengthValidationError => e
|
||||
Rails.logger.debug "Error fetching link #{@url}: #{e}"
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -31,12 +31,12 @@ class PostStatusService < BaseService
|
||||
sensitive: (options[:sensitive].nil? ? account.user&.setting_default_sensitive : options[:sensitive]),
|
||||
spoiler_text: options[:spoiler_text] || '',
|
||||
visibility: options[:visibility] || account.user&.setting_default_privacy,
|
||||
language: LanguageDetector.instance.detect(text, account),
|
||||
language: language_from_option(options[:language]) || LanguageDetector.instance.detect(text, account),
|
||||
application: options[:application])
|
||||
end
|
||||
|
||||
process_mentions_service.call(status)
|
||||
process_hashtags_service.call(status)
|
||||
process_mentions_service.call(status)
|
||||
|
||||
LinkCrawlWorker.perform_async(status.id) unless status.spoiler_text?
|
||||
DistributionWorker.perform_async(status.id)
|
||||
@@ -68,6 +68,10 @@ class PostStatusService < BaseService
|
||||
media
|
||||
end
|
||||
|
||||
def language_from_option(str)
|
||||
ISO_639.find(str)&.alpha2
|
||||
end
|
||||
|
||||
def process_mentions_service
|
||||
ProcessMentionsService.new
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user