user = insert(:user)
other_user = insert(:user, %{nickname: "shp"})
- {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
result = ActivityView.render("activity.json", activity: activity)
"favorited" => false,
"id" => activity.id,
"in_reply_to_status_id" => nil,
+ "in_reply_to_screen_name" => nil,
+ "in_reply_to_user_id" => nil,
+ "in_reply_to_profileurl" => nil,
+ "in_reply_to_ostatus_uri" => nil,
"is_local" => true,
"is_post_verb" => true,
"possibly_sensitive" => false,
"repeated" => false,
"statusnet_conversation_id" => convo_id,
"statusnet_html" =>
- "Hey <span><a href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
+ "Hey <span><a data-user=\"#{other_user.id}\" href=\"#{other_user.ap_id}\">@<span>shp</span></a></span>!",
"tags" => [],
"text" => "Hey @shp!",
"uri" => activity.data["object"]["id"],
- "user" => UserView.render("show.json", %{user: user})
+ "user" => UserView.render("show.json", %{user: user}),
+ "visibility" => "direct",
+ "summary" => nil
}
assert result == expected
{
TwitterAPI,
[],
- [context_to_conversation_id: fn(_) -> false end]
+ [context_to_conversation_id: fn _ -> false end]
+ },
+ {
+ User,
+ [:passthrough],
+ [get_cached_by_ap_id: fn _ -> nil end]
}
]
assert result["statusnet_conversation_id"] == convo_id
assert result["user"]
- refute called TwitterAPI.context_to_conversation_id(:_)
+ refute called(TwitterAPI.context_to_conversation_id(:_))
+ refute called(User.get_cached_by_ap_id(user.ap_id))
+ refute called(User.get_cached_by_ap_id(other_user.ap_id))
end
end
{:ok, like, _object} = CommonAPI.favorite(activity.id, other_user)
result = ActivityView.render("activity.json", activity: like)
+ activity = Pleroma.Activity.get_by_ap_id(activity.data["id"])
expected = %{
"activity_type" => "like",
"in_reply_to_status_id" => activity.id,
"is_local" => true,
"is_post_verb" => false,
+ "favorited_status" => ActivityView.render("activity.json", activity: activity),
+ "statusnet_html" => "shp favorited a status.",
+ "text" => "shp favorited a status.",
+ "uri" => "tag:#{like.data["id"]}:objectType=Favourite",
+ "user" => UserView.render("show.json", user: other_user)
+ }
+
+ assert result == expected
+ end
+
+ test "a like activity for deleted post" do
+ user = insert(:user)
+ other_user = insert(:user, %{nickname: "shp"})
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
+ {:ok, like, _object} = CommonAPI.favorite(activity.id, other_user)
+ CommonAPI.delete(activity.id, user)
+
+ result = ActivityView.render("activity.json", activity: like)
+
+ expected = %{
+ "activity_type" => "like",
+ "created_at" => like.data["published"] |> Utils.date_to_asctime(),
+ "external_url" => like.data["id"],
+ "id" => like.id,
+ "in_reply_to_status_id" => nil,
+ "is_local" => true,
+ "is_post_verb" => false,
+ "favorited_status" => nil,
"statusnet_html" => "shp favorited a status.",
"text" => "shp favorited a status.",
"uri" => "tag:#{like.data["id"]}:objectType=Favourite",