alias Pleroma.{Activity, Object, Upload, User}
import Ecto.Query
- def insert(map) when is_map(map) do
+ def insert(map, local \\ true) when is_map(map) do
map = map
|> Map.put_new_lazy("id", &generate_activity_id/0)
|> Map.put_new_lazy("published", &make_date/0)
map
end
- Repo.insert(%Activity{data: map})
+ Repo.insert(%Activity{data: map, local: local})
end
- def create(to, actor, context, object, additional \\ %{}, published \\ nil) do
+ def create(to, actor, context, object, additional \\ %{}, published \\ nil, local \\ true) do
published = published || make_date()
activity = %{
}
|> Map.merge(additional)
- with {:ok, activity} <- insert(activity) do
+ with {:ok, activity} <- insert(activity, local) do
if actor.local do
Pleroma.Web.Federator.enqueue(:publish, activity)
end
if Object.get_by_ap_id(id) do
{:error, "duplicate activity"}
else
- ActivityPub.create(to, actor, context, object, %{}, date)
+ ActivityPub.create(to, actor, context, object, %{}, date, false)
end
end
assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
+ assert activity.local == false
end
test "handle incoming notes - GS, subscription" do