Replace Object.normalize(activity.data[object] with Object.normalize(acitivty) to benefit from preloading

This commit is contained in:
rinpatch 2019-04-22 11:27:29 +03:00
parent 20deff75f1
commit d21d921def
6 changed files with 7 additions and 7 deletions

View file

@ -76,7 +76,7 @@ def render_activities(activities) do
|> Enum.map(fn activity -> |> Enum.map(fn activity ->
user = User.get_cached_by_ap_id(activity.data["actor"]) user = User.get_cached_by_ap_id(activity.data["actor"])
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity)
like_count = object["like_count"] || 0 like_count = object["like_count"] || 0
announcement_count = object["announcement_count"] || 0 announcement_count = object["announcement_count"] || 0

View file

@ -39,7 +39,7 @@ def fetch_object_from_id(id) do
Logger.info("Couldn't get object via AP, trying out OStatus fetching...") Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
case OStatus.fetch_activity_from_url(id) do case OStatus.fetch_activity_from_url(id) do
{:ok, [activity | _]} -> {:ok, Object.normalize(activity.data["object"], false)} {:ok, [activity | _]} -> {:ok, Object.normalize(activity, false)}
e -> e e -> e
end end
end end

View file

@ -168,7 +168,7 @@ def stream_out(activity) do
public = "https://www.w3.org/ns/activitystreams#Public" public = "https://www.w3.org/ns/activitystreams#Public"
if activity.data["type"] in ["Create", "Announce", "Delete"] do if activity.data["type"] in ["Create", "Announce", "Delete"] do
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity)
Pleroma.Web.Streamer.stream("user", activity) Pleroma.Web.Streamer.stream("user", activity)
Pleroma.Web.Streamer.stream("list", activity) Pleroma.Web.Streamer.stream("list", activity)

View file

@ -226,7 +226,7 @@ def make_note_data(
} }
if in_reply_to do if in_reply_to do
in_reply_to_object = Object.normalize(in_reply_to.data["object"]) in_reply_to_object = Object.normalize(in_reply_to)
object object
|> Map.put("inReplyTo", in_reply_to_object.data["id"]) |> Map.put("inReplyTo", in_reply_to_object.data["id"])

View file

@ -31,7 +31,7 @@ defp get_replied_to_activities(activities) do
|> Activity.create_by_object_ap_id() |> Activity.create_by_object_ap_id()
|> Repo.all() |> Repo.all()
|> Enum.reduce(%{}, fn activity, acc -> |> Enum.reduce(%{}, fn activity, acc ->
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity)
Map.put(acc, object.data["id"], activity) Map.put(acc, object.data["id"], activity)
end) end)
end end
@ -316,7 +316,7 @@ def render("attachment.json", %{attachment: attachment}) do
end end
def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity)
with nil <- replied_to_activities[object.data["inReplyTo"]] do with nil <- replied_to_activities[object.data["inReplyTo"]] do
# If user didn't participate in the thread # If user didn't participate in the thread

View file

@ -84,7 +84,7 @@ def to_simple_form(activity, user, with_author \\ false)
def to_simple_form(%{data: %{"type" => "Create"}} = activity, user, with_author) do def to_simple_form(%{data: %{"type" => "Create"}} = activity, user, with_author) do
h = fn str -> [to_charlist(str)] end h = fn str -> [to_charlist(str)] end
object = Object.normalize(activity.data["object"]) object = Object.normalize(activity)
updated_at = object.data["published"] updated_at = object.data["published"]
inserted_at = object.data["published"] inserted_at = object.data["published"]