}
with false <- user.local,
avatar <- make_avatar_object(doc),
bio <- string_from_xpath("//author[1]/summary", doc),
name <- string_from_xpath("//author[1]/poco:displayName", doc),
}
with false <- user.local,
avatar <- make_avatar_object(doc),
bio <- string_from_xpath("//author[1]/summary", doc),
name <- string_from_xpath("//author[1]/poco:displayName", doc),
new_data <- %{
avatar: avatar || old_data.avatar,
name: name || old_data.name,
new_data <- %{
avatar: avatar || old_data.avatar,
name: name || old_data.name,
},
false <- new_data == old_data do
change = Ecto.Changeset.change(user, new_data)
},
false <- new_data == old_data do
change = Ecto.Changeset.change(user, new_data)
def fetch_activity_from_atom_url(url) do
with true <- String.starts_with?(url, "http"),
def fetch_activity_from_atom_url(url) do
with true <- String.starts_with?(url, "http"),
Logger.debug("Trying to fetch #{url}")
with true <- String.starts_with?(url, "http"),
Logger.debug("Trying to fetch #{url}")
with true <- String.starts_with?(url, "http"),
- {:ok, %{body: body}} <-
- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
+ {:ok, %{body: body}} <- @httpoison.get(url, []),
{:ok, atom_url} <- get_atom_url(body) do
fetch_activity_from_atom_url(atom_url)
else
{:ok, atom_url} <- get_atom_url(body) do
fetch_activity_from_atom_url(atom_url)
else
- try do
- with {:ok, activities} when length(activities) > 0 <- fetch_activity_from_atom_url(url) do
- {:ok, activities}
- else
- _e ->
- with {:ok, activities} <- fetch_activity_from_html_url(url) do
- {:ok, activities}
- end
- end
- rescue
- e ->
- Logger.debug("Couldn't get #{url}: #{inspect(e)}")
- {:error, "Couldn't get #{url}: #{inspect(e)}"}
+ with {:ok, [_ | _] = activities} <- fetch_activity_from_atom_url(url) do
+ {:ok, activities}
+ else
+ _e -> fetch_activity_from_html_url(url)