Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.prettierignore`: Upstream added a line at the end of the file, while glitch-soc had its own extra lines. Took upstream's change. - `CONTRIBUTING.md`: We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes. Ported upstream changes. - `app/controllers/application_controller.rb`: Upstream made code style changes in a method that is entirely replaced in glitch-soc. Ignored the change. - `app/models/account.rb`: Code style changes textually close to glitch-soc-specific changes. Ported upstream changes. - `lib/sanitize_ext/sanitize_config.rb`: Upstream code style changes. Ignored them.
This commit is contained in:
@@ -28,7 +28,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
||||
raise Error, "Unsupported JSON-LD context for document #{uri}" unless supported_context?
|
||||
raise Error, "Unexpected object type for actor #{uri} (expected any of: #{SUPPORTED_TYPES})" unless expected_type?
|
||||
raise Error, "Actor #{uri} has moved to #{@json['movedTo']}" if break_on_redirect && @json['movedTo'].present?
|
||||
raise Error, "Actor #{uri} has no 'preferredUsername', which is a requirement for Mastodon compatibility" unless @json['preferredUsername'].present?
|
||||
raise Error, "Actor #{uri} has no 'preferredUsername', which is a requirement for Mastodon compatibility" if @json['preferredUsername'].blank?
|
||||
|
||||
@uri = @json['id']
|
||||
@username = @json['preferredUsername']
|
||||
@@ -50,6 +50,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
||||
|
||||
if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero?
|
||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
@@ -56,6 +56,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
||||
|
||||
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
|
||||
|
||||
|
@@ -36,6 +36,7 @@ class ActivityPub::FetchRepliesService < BaseService
|
||||
return collection_or_uri if collection_or_uri.is_a?(Hash)
|
||||
return unless @allow_synchronous_requests
|
||||
return if invalid_origin?(collection_or_uri)
|
||||
|
||||
fetch_resource_without_id_validation(collection_or_uri, nil, true)
|
||||
end
|
||||
|
||||
|
@@ -226,6 +226,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
|
||||
def property_values
|
||||
return unless @json['attachment'].is_a?(Array)
|
||||
|
||||
as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
|
||||
end
|
||||
|
||||
@@ -289,6 +290,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||
|
||||
def domain_block
|
||||
return @domain_block if defined?(@domain_block)
|
||||
|
||||
@domain_block = DomainBlock.rule_for(@domain)
|
||||
end
|
||||
|
||||
|
@@ -53,7 +53,7 @@ class BackupService < BaseService
|
||||
end
|
||||
end
|
||||
|
||||
archive_filename = ['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-') + '.tar.gz'
|
||||
archive_filename = "#{['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-')}.tar.gz"
|
||||
|
||||
@backup.dump = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file, filename: archive_filename)
|
||||
@backup.processed = true
|
||||
@@ -86,14 +86,14 @@ class BackupService < BaseService
|
||||
def dump_actor!(tar)
|
||||
actor = serialize(account, ActivityPub::ActorSerializer)
|
||||
|
||||
actor[:icon][:url] = 'avatar' + File.extname(actor[:icon][:url]) if actor[:icon]
|
||||
actor[:image][:url] = 'header' + File.extname(actor[:image][:url]) if actor[:image]
|
||||
actor[:icon][:url] = "avatar#{File.extname(actor[:icon][:url])}" if actor[:icon]
|
||||
actor[:image][:url] = "header#{File.extname(actor[:image][:url])}" if actor[:image]
|
||||
actor[:outbox] = 'outbox.json'
|
||||
actor[:likes] = 'likes.json'
|
||||
actor[:bookmarks] = 'bookmarks.json'
|
||||
|
||||
download_to_tar(tar, account.avatar, 'avatar' + File.extname(account.avatar.path)) if account.avatar.exists?
|
||||
download_to_tar(tar, account.header, 'header' + File.extname(account.header.path)) if account.header.exists?
|
||||
download_to_tar(tar, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
|
||||
download_to_tar(tar, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
|
||||
|
||||
json = Oj.dump(actor)
|
||||
|
||||
|
@@ -40,6 +40,7 @@ class FavouriteService < BaseService
|
||||
def bump_potential_friendship(account, status)
|
||||
ActivityTracker.increment('activity:interactions')
|
||||
return if account.following?(status.account_id)
|
||||
|
||||
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
|
||||
end
|
||||
|
||||
|
@@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService
|
||||
def html
|
||||
return @html if defined?(@html)
|
||||
|
||||
Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => Mastodon::Version.user_agent + ' Bot').perform do |res|
|
||||
Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => "#{Mastodon::Version.user_agent} Bot").perform do |res|
|
||||
# We follow redirects, and ideally we want to save the preview card for
|
||||
# the destination URL and not any link shortener in-between, so here
|
||||
# we set the URL to the one of the last response in the redirect chain
|
||||
|
@@ -114,7 +114,7 @@ class ImportService < BaseService
|
||||
status || ActivityPub::FetchRemoteStatusService.new.call(uri)
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
|
||||
nil
|
||||
rescue StandardError => e
|
||||
rescue => e
|
||||
Rails.logger.warn "Unexpected error when importing bookmark: #{e}"
|
||||
nil
|
||||
end
|
||||
|
@@ -9,10 +9,10 @@ class Keys::ClaimService < BaseService
|
||||
|
||||
def initialize(account, device_id, key_attributes = {})
|
||||
super(
|
||||
account: account,
|
||||
account: account,
|
||||
device_id: device_id,
|
||||
key_id: key_attributes[:key_id],
|
||||
key: key_attributes[:key],
|
||||
key_id: key_attributes[:key_id],
|
||||
key: key_attributes[:key],
|
||||
signature: key_attributes[:signature],
|
||||
)
|
||||
end
|
||||
|
@@ -23,9 +23,9 @@ class Keys::QueryService < BaseService
|
||||
|
||||
def initialize(attributes = {})
|
||||
super(
|
||||
device_id: attributes[:device_id],
|
||||
name: attributes[:name],
|
||||
identity_key: attributes[:identity_key],
|
||||
device_id: attributes[:device_id],
|
||||
name: attributes[:name],
|
||||
identity_key: attributes[:identity_key],
|
||||
fingerprint_key: attributes[:fingerprint_key],
|
||||
)
|
||||
@claim_url = attributes[:claim_url]
|
||||
|
@@ -31,6 +31,7 @@ class NotifyService < BaseService
|
||||
|
||||
def following_sender?
|
||||
return @following_sender if defined?(@following_sender)
|
||||
|
||||
@following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account)
|
||||
end
|
||||
|
||||
|
@@ -95,6 +95,7 @@ class PostStatusService < BaseService
|
||||
|
||||
def safeguard_mentions!(status)
|
||||
return if @options[:allowed_mentions].nil?
|
||||
|
||||
expected_account_ids = @options[:allowed_mentions].map(&:to_i)
|
||||
|
||||
unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) }
|
||||
@@ -184,8 +185,10 @@ class PostStatusService < BaseService
|
||||
|
||||
def bump_potential_friendship!
|
||||
return if !@status.reply? || @account.id == @status.in_reply_to_account_id
|
||||
|
||||
ActivityTracker.increment('activity:interactions')
|
||||
return if @account.following?(@status.in_reply_to_account_id)
|
||||
|
||||
PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply)
|
||||
end
|
||||
|
||||
|
@@ -44,11 +44,13 @@ class VoteService < BaseService
|
||||
|
||||
def distribute_poll!
|
||||
return if @poll.hide_totals?
|
||||
|
||||
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id)
|
||||
end
|
||||
|
||||
def queue_final_poll_check!
|
||||
return unless @poll.expires?
|
||||
|
||||
PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user