Try fetching shares.

This commit is contained in:
Roger Braun 2017-05-19 16:08:46 +02:00
parent 03b7b2fa24
commit 9d97be4413

View file

@ -63,8 +63,7 @@ defmodule Pleroma.Web.OStatus do
end end
def handle_share(entry, doc) do def handle_share(entry, doc) do
with [object] <- :xmerl_xpath.string('/entry/activity:object', entry), with {:ok, retweeted_activity} <- get_or_build_object(entry),
{:ok, retweeted_activity} <- handle_note(object, object),
{:ok, activity} <- make_share(entry, doc, retweeted_activity) do {:ok, activity} <- make_share(entry, doc, retweeted_activity) do
{:ok, activity, retweeted_activity} {:ok, activity, retweeted_activity}
else else
@ -81,6 +80,18 @@ defmodule Pleroma.Web.OStatus do
end end
end end
def get_or_build_object(entry) do
with {:ok, activity} <- get_or_try_fetching(entry) do
{:ok, activity}
else
_e ->
with [object] <- :xmerl_xpath.string('/entry/activity:object', entry) do
handle_note(object, object)
end
end
end
def get_or_try_fetching(entry) do def get_or_try_fetching(entry) do
Logger.debug("Trying to get entry from db") Logger.debug("Trying to get entry from db")
with id when not is_nil(id) <- string_from_xpath("//activity:object[1]/id", entry), with id when not is_nil(id) <- string_from_xpath("//activity:object[1]/id", entry),