use Pleroma.DataCase
alias Pleroma.Activity
alias Pleroma.Bookmark
+ alias Pleroma.ObanHelpers
+ alias Pleroma.Object
alias Pleroma.ThreadMute
import Pleroma.Factory
test "returns activities by it's objects AP ids" do
activity = insert(:note_activity)
- [found_activity] = Activity.get_all_create_by_object_ap_id(activity.data["object"]["id"])
+ object_data = Object.normalize(activity).data
+
+ [found_activity] = Activity.get_all_create_by_object_ap_id(object_data["id"])
assert activity == found_activity
end
test "returns the activity that created an object" do
activity = insert(:note_activity)
+ object_data = Object.normalize(activity).data
- found_activity = Activity.get_create_by_object_ap_id(activity.data["object"]["id"])
+ found_activity = Activity.get_create_by_object_ap_id(object_data["id"])
assert activity == found_activity
end
}
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
- {:ok, remote_activity} = Pleroma.Web.Federator.incoming_ap_doc(params)
+ {:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
+ {:ok, remote_activity} = ObanHelpers.perform(job)
%{local_activity: local_activity, remote_activity: remote_activity, user: user}
end
remote_activity: remote_activity,
user: user
} do
- assert [^remote_activity, ^local_activity] = Activity.search(user, "find me")
+ activities = Enum.sort_by(Activity.search(user, "find me"), & &1.id)
+
+ assert [^local_activity, ^remote_activity] = activities
end
test "find only local statuses for unauthenticated users", %{local_activity: local_activity} do
assert [^local_activity] = Activity.search(nil, "find me")
end
+
+ test "find only local statuses for unauthenticated users when `limit_to_local_content` is `:all`",
+ %{local_activity: local_activity} do
+ Pleroma.Config.put([:instance, :limit_to_local_content], :all)
+ assert [^local_activity] = Activity.search(nil, "find me")
+ Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
+ end
+
+ test "find all statuses for unauthenticated users when `limit_to_local_content` is `false`",
+ %{
+ local_activity: local_activity,
+ remote_activity: remote_activity
+ } do
+ Pleroma.Config.put([:instance, :limit_to_local_content], false)
+
+ activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
+
+ assert [^local_activity, ^remote_activity] = activities
+
+ Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
+ end
end
end