feat: enhance submit_urls method to include host
- Updated submit_urls method to accept a host parameter. - Modified the submit_urls call in each_slice to pass the host. - Added keyLocation to the data hash using the host. This change allows for more flexible URL submissions with hosts specific to the IndexNow API requirements. The host is now a parameter, improving the configurability of the submit process.
This commit is contained in:
parent
f6cf64e5b8
commit
67e15e1fee
@ -33,7 +33,7 @@ class SubmitToIndexnowWorker
|
||||
|
||||
# 分批提交 URLs (每批最多 10000 个 URLs,符合 IndexNow 限制)
|
||||
urls.each_slice(100) do |url_batch|
|
||||
submit_urls(url_batch)
|
||||
submit_urls(url_batch, @host)
|
||||
end
|
||||
|
||||
Rails.logger.info "Successfully submitted #{urls.size} URLs to IndexNow"
|
||||
@ -96,8 +96,9 @@ class SubmitToIndexnowWorker
|
||||
urls.uniq
|
||||
end
|
||||
|
||||
def submit_urls(urls)
|
||||
def submit_urls(urls, host)
|
||||
return if urls.empty?
|
||||
return if host.empty?
|
||||
|
||||
# 随机选择一个 IndexNow 端点
|
||||
endpoint = INDEXNOW_ENDPOINTS.sample
|
||||
@ -106,6 +107,7 @@ class SubmitToIndexnowWorker
|
||||
data = {
|
||||
host: URI.parse(@host).host,
|
||||
key: INDEXNOW_KEY,
|
||||
keyLocation: "#{host}/#{INDEXNOW_KEY}.txt",
|
||||
urlList: urls
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user