+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Web.OStatus do
@httpoison Application.get_env(:pleroma, :httpoison)
Logger.debug("Trying to get entry from db")
with id when not is_nil(id) <- string_from_xpath("//activity:object[1]/id", entry),
- %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
+ %Activity{} = activity <- Activity.get_create_by_object_ap_id(id) do
{:ok, activity}
else
_ ->
end
def fetch_activity_from_url(url) do
- 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)
end
+ rescue
+ e ->
+ Logger.debug("Couldn't get #{url}: #{inspect(e)}")
+ {:error, "Couldn't get #{url}: #{inspect(e)}"}
end
end