require Pleroma.Constants
+ describe "strip_report_status_data/1" do
+ test "does not break on issues with the reported activities" do
+ reporter = insert(:user)
+ target_account = insert(:user)
+ {:ok, activity} = CommonAPI.post(target_account, %{status: "foobar"})
+ context = Utils.generate_context_id()
+ content = "foobar"
+ post_id = activity.data["id"]
+
+ res =
+ Utils.make_flag_data(
+ %{
+ actor: reporter,
+ context: context,
+ account: target_account,
+ statuses: [%{"id" => post_id}],
+ content: content
+ },
+ %{}
+ )
+
+ res =
+ res
+ |> Map.put("object", res["object"] ++ [nil, 1, 5, "123"])
+
+ {:ok, activity} = Pleroma.Web.ActivityPub.ActivityPub.insert(res)
+
+ [user_id, object | _] = activity.data["object"]
+
+ {:ok, stripped} = Utils.strip_report_status_data(activity)
+
+ assert stripped.data["object"] == [user_id, object["id"]]
+ end
+ end
+
describe "fetch the latest Follow" do
test "fetches the latest Follow activity" do
%Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity)
assert Enum.sort(cc) == expected_cc
end
- test "does not adress actor's follower address if the activity is not public", %{
+ test "does not address actor's follower address if the activity is not public", %{
user: user,
other_user: other_user,
third_user: third_user
end
describe "get_cached_emoji_reactions/1" do
- test "returns the data or an emtpy list" do
+ test "returns the normalized data or an empty list" do
object = insert(:note)
assert Utils.get_cached_emoji_reactions(object) == []
object = insert(:note, data: %{"reactions" => [["x", ["lain"]]]})
- assert Utils.get_cached_emoji_reactions(object) == [["x", ["lain"]]]
+ assert Utils.get_cached_emoji_reactions(object) == [["x", ["lain"], nil]]
object = insert(:note, data: %{"reactions" => %{}})
assert Utils.get_cached_emoji_reactions(object) == []
end
end
+
+ describe "add_emoji_reaction_to_object/1" do
+ test "works with legacy 2-tuple format" do
+ user = insert(:user)
+ other_user = insert(:user)
+ third_user = insert(:user)
+
+ note =
+ insert(:note,
+ user: user,
+ data: %{
+ "reactions" => [["😿", [other_user.ap_id]]]
+ }
+ )
+
+ _activity = insert(:note_activity, user: user, note: note)
+
+ Utils.add_emoji_reaction_to_object(
+ %Activity{data: %{"content" => "😿", "actor" => third_user.ap_id}},
+ note
+ )
+ end
+ end
end