Fix ThreadResolveWorker getting queued with invalid URLs (#9628)
This commit is contained in:
parent
17cd91c777
commit
aa9a20cde0
|
@ -210,7 +210,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_thread(status)
|
def resolve_thread(status)
|
||||||
return unless status.reply? && status.thread.nil?
|
return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri)
|
||||||
ThreadResolveWorker.perform_async(status.id, in_reply_to_uri)
|
ThreadResolveWorker.perform_async(status.id, in_reply_to_uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base
|
||||||
save_emojis(status)
|
save_emojis(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
if thread? && status.thread.nil?
|
if thread? && status.thread.nil? && Request.valid_url?(thread.second)
|
||||||
Rails.logger.debug "Trying to attach #{status.id} (#{id}) to #{thread.first}"
|
Rails.logger.debug "Trying to attach #{status.id} (#{id}) to #{thread.first}"
|
||||||
ThreadResolveWorker.perform_async(status.id, thread.second)
|
ThreadResolveWorker.perform_async(status.id, thread.second)
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,6 +66,18 @@ class Request
|
||||||
(@account ? @headers.merge('Signature' => signature) : @headers).without(REQUEST_TARGET)
|
(@account ? @headers.merge('Signature' => signature) : @headers).without(REQUEST_TARGET)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def valid_url?(url)
|
||||||
|
begin
|
||||||
|
parsed_url = Addressable::URI.parse(url)
|
||||||
|
rescue Addressable::URI::InvalidURIError
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
%w(http https).include?(parsed_url.scheme) && parsed_url.host.present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_common_headers!
|
def set_common_headers!
|
||||||
|
|
Reference in New Issue