+ def render("activity.json", %{activity: %{data: %{"type" => "Follow"}} = activity} = opts) do
+ user = get_user(activity.data["actor"], opts)
+ created_at = activity.data["published"] || DateTime.to_iso8601(activity.inserted_at)
+ created_at = created_at |> Utils.date_to_asctime()
+
+ followed = get_user(activity.data["object"], opts)
+ text = "#{user.nickname} started following #{followed.nickname}"
+
+ %{
+ "id" => activity.id,
+ "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
+ "attentions" => [],
+ "statusnet_html" => text,
+ "text" => text,
+ "is_local" => activity.local,
+ "is_post_verb" => false,
+ "created_at" => created_at,
+ "in_reply_to_status_id" => nil,
+ "external_url" => activity.data["id"],
+ "activity_type" => "follow"
+ }
+ end
+
+ def render("activity.json", %{activity: %{data: %{"type" => "Announce"}} = activity} = opts) do
+ user = get_user(activity.data["actor"], opts)
+ created_at = activity.data["published"] |> Utils.date_to_asctime()
+ announced_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"])
+
+ text = "#{user.nickname} retweeted a status."
+
+ retweeted_status = render("activity.json", Map.merge(opts, %{activity: announced_activity}))
+
+ %{
+ "id" => activity.id,
+ "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
+ "statusnet_html" => text,
+ "text" => text,
+ "is_local" => activity.local,
+ "is_post_verb" => false,
+ "uri" => "tag:#{activity.data["id"]}:objectType=note",
+ "created_at" => created_at,
+ "retweeted_status" => retweeted_status,
+ "statusnet_conversation_id" => get_context_id(announced_activity, opts),
+ "external_url" => activity.data["id"],
+ "activity_type" => "repeat"
+ }
+ end
+
+ def render("activity.json", %{activity: %{data: %{"type" => "Like"}} = activity} = opts) do
+ user = get_user(activity.data["actor"], opts)
+ liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"])
+
+ created_at =
+ activity.data["published"]
+ |> Utils.date_to_asctime()
+
+ text = "#{user.nickname} favorited a status."
+
+ %{
+ "id" => activity.id,
+ "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
+ "statusnet_html" => text,
+ "text" => text,
+ "is_local" => activity.local,
+ "is_post_verb" => false,
+ "uri" => "tag:#{activity.data["id"]}:objectType=Favourite",
+ "created_at" => created_at,
+ "in_reply_to_status_id" => liked_activity.id,
+ "external_url" => activity.data["id"],
+ "activity_type" => "like"
+ }
+ end
+
+ def render(
+ "activity.json",
+ %{activity: %{data: %{"type" => "Create", "object" => object}} = activity} = opts
+ ) do
+ user = get_user(activity.data["actor"], opts)
+
+ created_at = object["published"] |> Utils.date_to_asctime()