1 defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
3 alias Pleroma.{User, Activity, Object}
4 alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter, ObjectRepresenter}
5 alias Pleroma.Web.ActivityPub.ActivityPub
6 alias Pleroma.Builders.UserBuilder
9 test "a like activity" do
11 note_activity = insert(:note_activity)
12 object = Object.get_by_ap_id(note_activity.data["object"]["id"])
14 {:ok, like_activity, _object} = ActivityPub.like(user, object)
15 status = ActivityRepresenter.to_map(like_activity, %{user: user, liked_activity: note_activity})
17 assert status["id"] == like_activity.id
18 assert status["in_reply_to_status_id"] == note_activity.id
20 note_activity = Activity.get_by_ap_id(note_activity.data["id"])
21 activity_actor = Repo.get_by(User, ap_id: note_activity.data["actor"])
22 liked_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user})
23 assert liked_status["favorited"] == true
27 {:ok, user} = UserBuilder.insert
28 {:ok, mentioned_user } = UserBuilder.insert(%{nickname: "shp", ap_id: "shp"})
29 {:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
37 "mediaType" => "image/jpg",
38 "href" => "http://example.org/image.jpg"
45 content_html = "Some content mentioning <a href='shp'>@shp</shp>"
46 content = HtmlSanitizeEx.strip_tags(content_html)
47 date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601
54 User.ap_followers(user),
55 "https://www.w3.org/ns/activitystreams#Public",
58 "actor" => User.ap_id(user),
62 "content" => content_html,
63 "inReplyToStatusId" => 213123,
64 "statusnetConversationId" => 4711,
77 "user" => UserRepresenter.to_map(user, %{for: follower}),
80 "statusnet_html" => content_html,
82 "is_post_verb" => true,
83 "created_at" => "Tue May 24 13:26:08 +0000 2016",
84 "in_reply_to_status_id" => 213123,
85 "statusnet_conversation_id" => 4711,
87 ObjectRepresenter.to_map(object)
90 UserRepresenter.to_map(mentioned_user, %{for: follower})
96 assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status