Merge branch 'remake-remodel-2' of git.pleroma.social:pleroma/pleroma into remake...
authorlain <lain@soykaf.club>
Thu, 26 Mar 2020 16:24:10 +0000 (17:24 +0100)
committerlain <lain@soykaf.club>
Thu, 26 Mar 2020 16:24:10 +0000 (17:24 +0100)
12 files changed:
COPYING
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/object_validator.ex
lib/pleroma/web/activity_pub/object_validators/common_validations.ex
lib/pleroma/web/activity_pub/object_validators/create_validator.ex
lib/pleroma/web/activity_pub/object_validators/like_validator.ex
lib/pleroma/web/activity_pub/object_validators/note_validator.ex
lib/pleroma/web/activity_pub/pipeline.ex
priv/repo/migrations/20190408123347_create_conversations.exs
test/web/activity_pub/object_validators/note_validator_test.exs
test/web/activity_pub/pipeline_test.exs
test/web/activity_pub/side_effects_test.exs

diff --git a/COPYING b/COPYING
index 0aede0fbaf27be6332059f9c50f4a0e436f796ac..3140c8038e6401ca9e11a972621672554c87c03f 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-Unless otherwise stated this repository is copyright © 2017-2019
+Unless otherwise stated this repository is copyright © 2017-2020
 Pleroma Authors <https://pleroma.social/>, and is distributed under
 The GNU Affero General Public License Version 3, you should have received a
 copy of the license file as AGPL-3.
@@ -23,7 +23,7 @@ priv/static/images/pleroma-fox-tan-shy.png
 
 ---
 
-The following files are copyright © 2017-2019 Pleroma Authors
+The following files are copyright © 2017-2020 Pleroma Authors
 <https://pleroma.social/>, and are distributed under the Creative Commons
 Attribution-ShareAlike 4.0 International license, you should have received
 a copy of the license file as CC-BY-SA-4.0.
index dd4b04185c97603175f4d6552c9e6465533d11a9..55f4de693803d2682f5e5ee98b583dab841c52b9 100644 (file)
@@ -125,24 +125,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   def increase_poll_votes_if_vote(_create_data), do: :noop
 
-  @spec insert(map(), boolean(), boolean(), boolean()) :: {:ok, Activity.t()} | {:error, any()}
-  # TODO rewrite in with style
   @spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
   def persist(object, meta) do
-    local = Keyword.fetch!(meta, :local)
-    {recipients, _, _} = get_recipients(object)
-
-    {:ok, activity} =
-      Repo.insert(%Activity{
-        data: object,
-        local: local,
-        recipients: recipients,
-        actor: object["actor"]
-      })
-
-    {:ok, activity, meta}
+    with local <- Keyword.fetch!(meta, :local),
+         {recipients, _, _} <- get_recipients(object),
+         {:ok, activity} <-
+           Repo.insert(%Activity{
+             data: object,
+             local: local,
+             recipients: recipients,
+             actor: object["actor"]
+           }) do
+      {:ok, activity, meta}
+    end
   end
 
+  @spec insert(map(), boolean(), boolean(), boolean()) :: {:ok, Activity.t()} | {:error, any()}
   def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
     with nil <- Activity.normalize(map),
          map <- lazy_put_activity_defaults(map, fake),
index 9b2889e927bc14f39a5bbdc9a8df844930027fdb..dc4bce0595a12c409475206b2aed0e7222b7ce18 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidator do
index db0e2072dbd53198b875ab034a4afce9835e03a1..b479c391837f1ccf20dfabd5134b562054e4dbb8 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations do
@@ -21,11 +21,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations do
 
   def validate_object_presence(cng, field_name \\ :object) do
     cng
-    |> validate_change(field_name, fn field_name, actor ->
-      if Object.get_cached_by_ap_id(actor) do
+    |> validate_change(field_name, fn field_name, object ->
+      if Object.get_cached_by_ap_id(object) do
         []
       else
-        [{field_name, "can't find user"}]
+        [{field_name, "can't find object"}]
       end
     end)
   end
index 872a12c48852dba24c9a96d8f86e4dc06c9a5918..926804ce74c18311fbf0516e9ea8ae7a21245b75 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateNoteValidator do
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateNoteValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, :string, primary_key: true)
+    field(:id, Types.ObjectID, primary_key: true)
     field(:actor, Types.ObjectID)
     field(:type, :string)
     field(:to, {:array, :string})
index ccbc7d071761557fe449617da78bb679036af04d..49546ceaaa22c33d331e5c5f9cb9818fa147da1c 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, :string, primary_key: true)
+    field(:id, Types.ObjectID, primary_key: true)
     field(:type, :string)
     field(:object, Types.ObjectID)
     field(:actor, Types.ObjectID)
index eea15ce1cf8750fbafaa5fbdbc19380cc69550e6..c95b622e48e77f6b1045171d51e63cee4c10d64a 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, :string, primary_key: true)
+    field(:id, Types.ObjectID, primary_key: true)
     field(:to, {:array, :string}, default: [])
     field(:cc, {:array, :string}, default: [])
     field(:bto, {:array, :string}, default: [])
index 0068d60be69bc5ab861773e70892bd31430ba01d..7ccee54c9d829d14204bde726a2958c6e41c54c5 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.Pipeline do
index d75459e82f4a32069b75e81323b24bc7aa1bf2f3..3eaa6136c714d443f537d87b0e1fa661a69585b7 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Repo.Migrations.CreateConversations do
index 2bcd75e2574cf374de86b7773638ce3e176df97d..30c481ffbc8329fd74cafedf634ffd345ad4dcdf 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidatorTest do
index 318d306af3a8c5b79fc8411858a8d606ad3df9ec..f3c43749889928b41cf515b45d8960248d0e8b50 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.PipelineTest do
index ef91954ae8dcd4a02d082f95bb6dd70b0c616d06..b67bd14b36e08f07c57629aefa378a7991acdcb7 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.SideEffectsTest do