From 9d97be441396e0b8857e52c7b3ff0105f3c635ea Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 19 May 2017 16:08:46 +0200 Subject: [PATCH] Try fetching shares. --- lib/pleroma/web/ostatus/ostatus.ex | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index 222e18350..02fc273cf 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -63,8 +63,7 @@ defmodule Pleroma.Web.OStatus do end def handle_share(entry, doc) do - with [object] <- :xmerl_xpath.string('/entry/activity:object', entry), - {:ok, retweeted_activity} <- handle_note(object, object), + with {:ok, retweeted_activity} <- get_or_build_object(entry), {:ok, activity} <- make_share(entry, doc, retweeted_activity) do {:ok, activity, retweeted_activity} else @@ -81,6 +80,18 @@ defmodule Pleroma.Web.OStatus do 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 Logger.debug("Trying to get entry from db") with id when not is_nil(id) <- string_from_xpath("//activity:object[1]/id", entry), -- 2.45.2