build_cachex("failed_proxy_url", limit: 2500),
build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000),
build_cachex("translations", default_ttl: :timer.hours(24 * 30), limit: 2500),
- build_cachex("instances", default_ttl: :timer.hours(24), limit: 2500)
+ build_cachex("instances", default_ttl: :timer.hours(24), ttl_interval: 1000, limit: 2500)
]
end
favicon = scrape_favicon(uri)
nodeinfo = scrape_nodeinfo(uri)
- {:ok, instance} =
- existing_record
- |> changeset(%{
- host: host,
- favicon: favicon,
- nodeinfo: nodeinfo,
- metadata_updated_at: NaiveDateTime.utc_now()
- })
- |> Repo.update()
-
- @cachex.put(:instances_cache, "instances:#{host}", instance)
+ existing_record
+ |> changeset(%{
+ host: host,
+ favicon: favicon,
+ nodeinfo: nodeinfo,
+ metadata_updated_at: NaiveDateTime.utc_now()
+ })
+ |> Repo.update()
else
{:discard, "Does not require update"}
end
metadata_updated_at: NaiveDateTime.utc_now()
})
|> Repo.insert()
-
- @cachex.put(:instances_cache, "instances:#{host}", instance)
end
end
}
end)
- assert {:ok, true} ==
+ assert {:ok, %Instance{host: "favicon.example.org"}} =
Instance.update_metadata(URI.parse("https://favicon.example.org/"))
{:ok, instance} = Instance.get_cached_by_url("https://favicon.example.org/")
}
end)
- assert {:ok, true} ==
+ assert {:ok, %Instance{host: "long-favicon.example.org"}} =
Instance.update_metadata(URI.parse("https://long-favicon.example.org/"))
{:ok, instance} = Instance.get_cached_by_url("https://long-favicon.example.org/")
end)
refute capture_log(fn ->
- assert {:ok, true} =
+ assert {:ok, %Instance{host: "no-favicon.example.org"}} =
Instance.update_metadata(URI.parse("https://no-favicon.example.org/"))
end) =~ "Instance.update_metadata(\"https://no-favicon.example.org/\") error: "
end
}
end)
- assert {:ok, true} ==
+ assert {:ok, %Instance{host: "bad-nodeinfo.example.org"}} =
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
}
end)
- assert {:ok, true} ==
+ assert {:ok, %Instance{host: "bad-nodeinfo.example.org"}} =
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
}
end)
- assert {:ok, true} ==
+ assert {:ok, %Instance{host: "bad-nodeinfo.example.org"}} =
Instance.update_metadata(URI.parse("https://bad-nodeinfo.example.org/"))
{:ok, instance} = Instance.get_cached_by_url("https://bad-nodeinfo.example.org/")
ReportView.render("show.json", Report.extract_report_info(activity))
|> Map.delete(:created_at)
- assert result == expected
+ assert Jason.encode!(result) == Jason.encode!(expected)
end
test "includes reported statuses" do