TwitterAPI: Fix mentions.
[akkoma] / lib / pleroma / web / twitter_api / representers / activity_representer.ex
index f9f9bd7b4bee118988f08da10231219e330ef2b0..b0dfeaf39066c69b588e90d22162813b7f08082e 100644 (file)
@@ -56,7 +56,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
     }
   end
 
-  def to_map(%Activity{data: %{"type" => "Follow", "published" => created_at, "object" => followed_id}} = activity, %{user: user} = opts) do
+  def to_map(%Activity{data: %{"type" => "Follow", "object" => followed_id}} = activity, %{user: user} = opts) do
+    created_at = activity.data["published"] || (DateTime.to_iso8601(activity.inserted_at))
     created_at = created_at |> Utils.date_to_asctime
 
     followed = User.get_cached_by_ap_id(followed_id)
@@ -125,7 +126,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
 
     mentions = opts[:mentioned] || []
 
-    attentions = activity.data["to"]
+    attentions = activity.recipients
     |> Enum.map(fn (ap_id) -> Enum.find(mentions, fn(user) -> ap_id == user.ap_id end) end)
     |> Enum.filter(&(&1))
     |> Enum.map(fn (user) -> UserView.render("show.json", %{user: user, for: opts[:for]}) end)