+ def add_external_url(note, entry) do
+ url = XML.string_from_xpath("//link[@rel='alternate' and @type='text/html']/@href", entry)
+ Map.put(note, "external_url", url)
+ end
+
+ def fetch_replied_to_activity(entry, inReplyTo) do
+ with %Activity{} = activity <- Activity.get_create_by_object_ap_id(inReplyTo) do
+ activity
+ else
+ _e ->
+ with inReplyToHref when not is_nil(inReplyToHref) <-
+ XML.string_from_xpath("//thr:in-reply-to[1]/@href", entry),
+ {:ok, [activity | _]} <- OStatus.fetch_activity_from_url(inReplyToHref) do
+ activity
+ else
+ _e -> nil
+ end
+ end
+ end
+
+ # TODO: Clean this up a bit.