Skip to content

Commit

Permalink
.well-known/nodeinfoのフォーマットをチェックしてjsonじゃなければtitleを空文字列にする
Browse files Browse the repository at this point in the history
  • Loading branch information
kaias1jp committed Oct 30, 2021
1 parent 09e50a9 commit af79bef
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/workers/crawl_worker.rb
Expand Up @@ -91,7 +91,19 @@ def perform(uri)
end
response = conn3.get '/.well-known/nodeinfo'
if response.status == 200 then
if response.headers['content-type'].include?("json") == true then
if response.headers['content-type'].include?("json") == false then

conn2 = Faraday.new(:url => ENV["SERVER_URL"]) do |builder|
builder.request :json # form-encode POST params
builder.adapter Faraday.default_adapter # make requests with Net::HTTP
builder.options[:open_timeout] = 10 # コネクションを開くまでに待つ最大秒数i
builder.options[:timeout] = 10 # データ読み込みまでに待つ最大秒数
builder.token_auth ENV["SERVER_TOKEN"]
end
conn2.headers["Content-Type"] = "application/json"
obj = {"title" => ""}
res = conn2.put("/api/v1/sites/"+value["id"].to_s, obj.to_json)
else
hash2 = JSON.parse(response.body)
uri = URI.parse(hash2["links"][0]["href"])
p uri.path
Expand Down

0 comments on commit af79bef

Please sign in to comment.