Fix specs, add local marker to actitivies.
authorRoger Braun <roger@rogerbraun.net>
Tue, 2 May 2017 08:43:35 +0000 (10:43 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 2 May 2017 08:43:35 +0000 (10:43 +0200)
lib/pleroma/activity.ex
priv/repo/migrations/20170502083023_add_local_field_to_activities.exs [new file with mode: 0644]
test/support/builders/activity_builder.ex
test/web/twitter_api/twitter_api_test.exs

index 80d96d0f20bc0e765e05131833a24c712b9adace..d77c8899749a7dd16e568829e3a77340392afa31 100644 (file)
@@ -5,6 +5,7 @@ defmodule Pleroma.Activity do
 
   schema "activities" do
     field :data, :map
+    field :local, :boolean, default: true
 
     timestamps()
   end
diff --git a/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs b/priv/repo/migrations/20170502083023_add_local_field_to_activities.exs
new file mode 100644 (file)
index 0000000..088d68f
--- /dev/null
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.AddLocalFieldToActivities do
+  use Ecto.Migration
+
+  def change do
+    alter table(:activities) do
+      add :local, :boolean, default: true
+    end
+
+    create index(:activities, [:local])
+  end
+end
index 0f9cd0d15cae388bc0122bfa47cbab75f6aa9586..16011edbfda2d9d386e0034b19679032b917e758 100644 (file)
@@ -5,7 +5,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
   def build(data \\ %{}, opts \\ %{}) do
     user = opts[:user] || Pleroma.Factory.insert(:user)
     activity = %{
-      "id" => 1,
+      "id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id,
       "actor" => user.ap_id,
       "to" => ["https://www.w3.org/ns/activitystreams#Public"],
       "object" => %{
@@ -23,7 +23,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
 
   def insert_list(times, data \\ %{}, opts \\ %{}) do
     Enum.map(1..times, fn (n) ->
-      {:ok, activity} = insert(Map.merge(data, %{"id" => n}))
+      {:ok, activity} = insert(data)
       activity
     end)
   end
index 207d9d12a048f2b033d70476e41fccb029277636..57dcddd4c16de7a71a64395f7d50743486d37d76 100644 (file)
@@ -40,6 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
     assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
     assert Enum.member?(get_in(activity.data, ["to"]), "shp")
+    assert activity.local == true
 
     # Add a context
     assert is_binary(get_in(activity.data, ["context"]))