moving custom ecto types in context folders
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Tue, 16 Jun 2020 14:50:33 +0000 (17:50 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Tue, 16 Jun 2020 14:50:33 +0000 (17:50 +0300)
26 files changed:
lib/pleroma/config/config_db.ex
lib/pleroma/ecto_type/activity_pub/object_validators/date_time.ex [moved from lib/pleroma/web/activity_pub/object_validators/types/date_time.ex with 77% similarity]
lib/pleroma/ecto_type/activity_pub/object_validators/object_id.ex [moved from lib/pleroma/web/activity_pub/object_validators/types/object_id.ex with 69% similarity]
lib/pleroma/ecto_type/activity_pub/object_validators/recipients.ex [moved from lib/pleroma/web/activity_pub/object_validators/types/recipients.ex with 64% similarity]
lib/pleroma/ecto_type/activity_pub/object_validators/safe_text.ex [moved from lib/pleroma/web/activity_pub/object_validators/types/safe_text.ex with 85% similarity]
lib/pleroma/ecto_type/activity_pub/object_validators/uri.ex [moved from lib/pleroma/web/activity_pub/object_validators/types/uri.ex with 63% similarity]
lib/pleroma/ecto_type/config/atom.ex [moved from lib/pleroma/config/type/atom.ex with 66% similarity]
lib/pleroma/ecto_type/config/binary_value.ex [moved from lib/pleroma/config/type/binary_value.ex with 65% similarity]
lib/pleroma/signature.ex
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/object_validator.ex
lib/pleroma/web/activity_pub/object_validators/announce_validator.ex
lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex
lib/pleroma/web/activity_pub/object_validators/create_chat_message_validator.ex
lib/pleroma/web/activity_pub/object_validators/create_note_validator.ex
lib/pleroma/web/activity_pub/object_validators/delete_validator.ex
lib/pleroma/web/activity_pub/object_validators/emoji_react_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/object_validators/undo_validator.ex
lib/pleroma/web/activity_pub/object_validators/url_object_validator.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/object_validators/types/date_time_test.exs
test/web/activity_pub/object_validators/types/object_id_test.exs
test/web/activity_pub/object_validators/types/recipients_test.exs
test/web/activity_pub/object_validators/types/safe_text_test.exs

index 30bd51b05a2ab68ec70e2db8ee35b8bb15026215..2f4eb8581dba09e75552acea45388f230f7b9108 100644 (file)
@@ -23,9 +23,9 @@ defmodule Pleroma.ConfigDB do
   ]
 
   schema "config" do
-    field(:key, Pleroma.Config.Type.Atom)
-    field(:group, Pleroma.Config.Type.Atom)
-    field(:value, Pleroma.Config.Type.BinaryValue)
+    field(:key, Pleroma.EctoType.Config.Atom)
+    field(:group, Pleroma.EctoType.Config.Atom)
+    field(:value, Pleroma.EctoType.Config.BinaryValue)
     field(:db, {:array, :string}, virtual: true, default: [])
 
     timestamps()
similarity index 77%
rename from lib/pleroma/web/activity_pub/object_validators/types/date_time.ex
rename to lib/pleroma/ecto_type/activity_pub/object_validators/date_time.ex
index 4f412fcde5ab0643f7b953382bf13551537ce27b..d852c0abd69cc6db39b05a7c679a4ffce9264630 100644 (file)
@@ -1,4 +1,8 @@
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.DateTime do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime do
   @moduledoc """
   The AP standard defines the date fields in AP as xsd:DateTime. Elixir's
   DateTime can't parse this, but it can parse the related iso8601. This
similarity index 69%
rename from lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
rename to lib/pleroma/ecto_type/activity_pub/object_validators/object_id.ex
index f71f763704be08664ec3b3b0c3461d7c6c008e9c..8034235b082cf28b0b76be0b372a377e1eb1379f 100644 (file)
@@ -1,4 +1,8 @@
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID do
   use Ecto.Type
 
   def type, do: :string
similarity index 64%
rename from lib/pleroma/web/activity_pub/object_validators/types/recipients.ex
rename to lib/pleroma/ecto_type/activity_pub/object_validators/recipients.ex
index 408e0f6ee6e114521a85aabf0f8dabed9cdbafcb..205527a962bf52b40ef5e52b9b24af53ecf5dac6 100644 (file)
@@ -1,7 +1,11 @@
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.Recipients do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients do
   use Ecto.Type
 
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
 
   def type, do: {:array, ObjectID}
 
similarity index 85%
rename from lib/pleroma/web/activity_pub/object_validators/types/safe_text.ex
rename to lib/pleroma/ecto_type/activity_pub/object_validators/safe_text.ex
index 95c948123621aa4c9a61b119353e42b6ad7aca16..7f0405c7b66268fc6e0297300e9b9270fc2aa2fe 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeText do
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.SafeText do
   use Ecto.Type
 
   alias Pleroma.HTML
similarity index 63%
rename from lib/pleroma/web/activity_pub/object_validators/types/uri.ex
rename to lib/pleroma/ecto_type/activity_pub/object_validators/uri.ex
index 24845bcc0aa526d86bf45f8b5c1333c8c6a156a8..2054c26be08e212eb8e020f2cf38e6699060ce64 100644 (file)
@@ -1,4 +1,8 @@
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.Uri do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Uri do
   use Ecto.Type
 
   def type, do: :string
similarity index 66%
rename from lib/pleroma/config/type/atom.ex
rename to lib/pleroma/ecto_type/config/atom.ex
index 38786928465428328826c004b6a8e2a3b59491ea..df565d432f47248d85f79e2afe21b677d5622135 100644 (file)
@@ -1,4 +1,8 @@
-defmodule Pleroma.Config.Type.Atom do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.Config.Atom do
   use Ecto.Type
 
   def type, do: :atom
similarity index 65%
rename from lib/pleroma/config/type/binary_value.ex
rename to lib/pleroma/ecto_type/config/binary_value.ex
index 17c5524a345652b7199166399dac153e5fa425f1..bbd2608c526900a67b2226532df567ae66a50d6a 100644 (file)
@@ -1,4 +1,8 @@
-defmodule Pleroma.Config.Type.BinaryValue do
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.EctoType.Config.BinaryValue do
   use Ecto.Type
 
   def type, do: :term
index d01728361c4df3e626f723dd13ad81fb4b962175..3aa6909d2f1652bf79f6312381a12de130fcd232 100644 (file)
@@ -5,10 +5,10 @@
 defmodule Pleroma.Signature do
   @behaviour HTTPSignatures.Adapter
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Keys
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   def key_id_to_actor_id(key_id) do
     uri =
@@ -24,7 +24,7 @@ defmodule Pleroma.Signature do
 
     maybe_ap_id = URI.to_string(uri)
 
-    case Types.ObjectID.cast(maybe_ap_id) do
+    case ObjectValidators.ObjectID.cast(maybe_ap_id) do
       {:ok, ap_id} ->
         {:ok, ap_id}
 
index 52ac9052baa923216856b383da670f940a235b87..686ab012363bae9fb4c59fcc14aada64c0f43e2c 100644 (file)
@@ -14,6 +14,7 @@ defmodule Pleroma.User do
   alias Pleroma.Config
   alias Pleroma.Conversation.Participation
   alias Pleroma.Delivery
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Emoji
   alias Pleroma.FollowingRelationship
   alias Pleroma.Formatter
@@ -30,7 +31,6 @@ defmodule Pleroma.User do
   alias Pleroma.Web
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Builder
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
   alias Pleroma.Web.ActivityPub.Pipeline
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.CommonAPI
@@ -115,7 +115,7 @@ defmodule Pleroma.User do
     field(:is_admin, :boolean, default: false)
     field(:show_role, :boolean, default: true)
     field(:settings, :map, default: nil)
-    field(:uri, Types.Uri, default: nil)
+    field(:uri, ObjectValidators.Uri, default: nil)
     field(:hide_followers_count, :boolean, default: false)
     field(:hide_follows_count, :boolean, default: false)
     field(:hide_followers, :boolean, default: false)
index c01c5f78067dc57395e0ce90ce098d86e74c112d..3d699e8a5954a382d467eb1dcbdbf901fb1c31c3 100644 (file)
@@ -10,6 +10,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
   """
 
   alias Pleroma.Object
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator
   alias Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator
@@ -17,7 +18,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
   alias Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator
   alias Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator
   alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
   alias Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator
 
   @spec validate(map(), keyword()) :: {:ok, map(), keyword()} | {:error, any()}
@@ -120,7 +120,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
   def stringify_keys(object), do: object
 
   def fetch_actor(object) do
-    with {:ok, actor} <- Types.ObjectID.cast(object["actor"]) do
+    with {:ok, actor} <- ObjectValidators.ObjectID.cast(object["actor"]) do
       User.get_or_fetch_by_ap_id(actor)
     end
   end
index 40f861f477b83d64dc72d7893bc6bccc72e89daf..6f757f49ce008cecede0a29646f1369c6855eb52 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator do
   use Ecto.Schema
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Object
   alias Pleroma.User
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
 
@@ -19,14 +19,14 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:type, :string)
-    field(:object, Types.ObjectID)
-    field(:actor, Types.ObjectID)
+    field(:object, ObjectValidators.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
     field(:context, :string, autogenerate: {Utils, :generate_context_id, []})
-    field(:to, Types.Recipients, default: [])
-    field(:cc, Types.Recipients, default: [])
-    field(:published, Types.DateTime)
+    field(:to, ObjectValidators.Recipients, default: [])
+    field(:cc, ObjectValidators.Recipients, default: [])
+    field(:published, ObjectValidators.DateTime)
   end
 
   def cast_and_validate(data) do
index 138736f230f8c70a50ed353eb795b2771ac0771d..c481d79e0483aa11c7ca68da75943127cb275be8 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator do
   use Ecto.Schema
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   import Ecto.Changeset
   import Pleroma.Web.ActivityPub.Transmogrifier, only: [fix_emoji: 1]
@@ -16,12 +16,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator do
   @derive Jason.Encoder
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
-    field(:to, Types.Recipients, default: [])
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
+    field(:to, ObjectValidators.Recipients, default: [])
     field(:type, :string)
-    field(:content, Types.SafeText)
-    field(:actor, Types.ObjectID)
-    field(:published, Types.DateTime)
+    field(:content, ObjectValidators.SafeText)
+    field(:actor, ObjectValidators.ObjectID)
+    field(:published, ObjectValidators.DateTime)
     field(:emoji, :map, default: %{})
 
     embeds_one(:attachment, AttachmentValidator)
index fc582400b5ff7dc2831b90165e2eb4e85f748a9a..7269f9ff0b8a60dc8d45afc0e5b071de03a26272 100644 (file)
@@ -7,9 +7,9 @@
 # - doesn't embed, will only get the object id
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateChatMessageValidator do
   use Ecto.Schema
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
 
   alias Pleroma.Object
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   import Ecto.Changeset
   import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
@@ -17,11 +17,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateChatMessageValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
-    field(:actor, Types.ObjectID)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
+    field(:actor, ObjectValidators.ObjectID)
     field(:type, :string)
-    field(:to, Types.Recipients, default: [])
-    field(:object, Types.ObjectID)
+    field(:to, ObjectValidators.Recipients, default: [])
+    field(:object, ObjectValidators.ObjectID)
   end
 
   def cast_and_apply(data) do
index 926804ce74c18311fbf0516e9ea8ae7a21245b75..316bd0c073a248b6395d5b7431a0da3531086761 100644 (file)
@@ -5,16 +5,16 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateNoteValidator do
   use Ecto.Schema
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   import Ecto.Changeset
 
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
-    field(:actor, Types.ObjectID)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
+    field(:actor, ObjectValidators.ObjectID)
     field(:type, :string)
     field(:to, {:array, :string})
     field(:cc, {:array, :string})
index e5d08eb5c7f0b380fa8733b990db348ed4e27cbc..93a7b0e0bc3757cf440540f0e7ad231b06d2820e 100644 (file)
@@ -6,8 +6,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
   use Ecto.Schema
 
   alias Pleroma.Activity
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.User
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   import Ecto.Changeset
   import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
@@ -15,13 +15,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:type, :string)
-    field(:actor, Types.ObjectID)
-    field(:to, Types.Recipients, default: [])
-    field(:cc, Types.Recipients, default: [])
-    field(:deleted_activity_id, Types.ObjectID)
-    field(:object, Types.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
+    field(:to, ObjectValidators.Recipients, default: [])
+    field(:cc, ObjectValidators.Recipients, default: [])
+    field(:deleted_activity_id, ObjectValidators.ObjectID)
+    field(:object, ObjectValidators.ObjectID)
   end
 
   def cast_data(data) do
index e87519c59e6c34b879e23e28db2bf077bf1df33d..a543af1f82c598dea8824cb9358223d4ac8678ed 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
   use Ecto.Schema
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Object
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
 
   import Ecto.Changeset
   import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
@@ -14,10 +14,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:type, :string)
-    field(:object, Types.ObjectID)
-    field(:actor, Types.ObjectID)
+    field(:object, ObjectValidators.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
     field(:context, :string)
     field(:content, :string)
     field(:to, {:array, :string}, default: [])
index 034f25492d5affab99bda6d113bc58c29c950419..493e4c24704cf72498ddd4a37a4e03e51ca7c7f8 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do
   use Ecto.Schema
 
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.Object
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
   alias Pleroma.Web.ActivityPub.Utils
 
   import Ecto.Changeset
@@ -15,13 +15,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:type, :string)
-    field(:object, Types.ObjectID)
-    field(:actor, Types.ObjectID)
+    field(:object, ObjectValidators.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
     field(:context, :string)
-    field(:to, Types.Recipients, default: [])
-    field(:cc, Types.Recipients, default: [])
+    field(:to, ObjectValidators.Recipients, default: [])
+    field(:cc, ObjectValidators.Recipients, default: [])
   end
 
   def cast_and_validate(data) do
@@ -67,7 +67,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do
 
     with {[], []} <- {to, cc},
          %Object{data: %{"actor" => actor}} <- Object.get_cached_by_ap_id(object),
-         {:ok, actor} <- Types.ObjectID.cast(actor) do
+         {:ok, actor} <- ObjectValidators.ObjectID.cast(actor) do
       cng
       |> put_change(:to, [actor])
     else
index 462a5620a239aece445d324f3ac07a99e1d11fb0..a10728ac650ec4e8f6d2feb444dd0404b03f5f00 100644 (file)
@@ -5,14 +5,14 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
   use Ecto.Schema
 
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
 
   import Ecto.Changeset
 
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:to, {:array, :string}, default: [])
     field(:cc, {:array, :string}, default: [])
     field(:bto, {:array, :string}, default: [])
@@ -22,10 +22,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
     field(:type, :string)
     field(:content, :string)
     field(:context, :string)
-    field(:actor, Types.ObjectID)
-    field(:attributedTo, Types.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
+    field(:attributedTo, ObjectValidators.ObjectID)
     field(:summary, :string)
-    field(:published, Types.DateTime)
+    field(:published, ObjectValidators.DateTime)
     # TODO: Write type
     field(:emoji, :map, default: %{})
     field(:sensitive, :boolean, default: false)
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
     field(:like_count, :integer, default: 0)
     field(:announcement_count, :integer, default: 0)
     field(:inRepyTo, :string)
-    field(:uri, Types.Uri)
+    field(:uri, ObjectValidators.Uri)
 
     field(:likes, {:array, :string}, default: [])
     field(:announcements, {:array, :string}, default: [])
index d0ba418e8c289a91fa8e131b297a136fc7806d05..e8d2d39c124c9f819bd2ea0a654b0783b80ad61f 100644 (file)
@@ -6,7 +6,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator do
   use Ecto.Schema
 
   alias Pleroma.Activity
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
 
   import Ecto.Changeset
   import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
@@ -14,10 +14,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, Types.ObjectID, primary_key: true)
+    field(:id, ObjectValidators.ObjectID, primary_key: true)
     field(:type, :string)
-    field(:object, Types.ObjectID)
-    field(:actor, Types.ObjectID)
+    field(:object, ObjectValidators.ObjectID)
+    field(:actor, ObjectValidators.ObjectID)
     field(:to, {:array, :string}, default: [])
     field(:cc, {:array, :string}, default: [])
   end
index 47e23115002718432491fc4ea320f4938cee5b94..f64fac46daffa28ef292960f8106d120977bb750 100644 (file)
@@ -1,14 +1,18 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.UrlObjectValidator do
   use Ecto.Schema
 
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
 
   import Ecto.Changeset
   @primary_key false
 
   embedded_schema do
     field(:type, :string)
-    field(:href, Types.Uri)
+    field(:href, ObjectValidators.Uri)
     field(:mediaType, :string)
   end
 
index 985921aa0dd451be0d8edfe6df3014a9815e4a4c..851f474b88c060c44aad6d2ad7c5b04e90a46289 100644 (file)
@@ -8,6 +8,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   """
   alias Pleroma.Activity
   alias Pleroma.EarmarkRenderer
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators
   alias Pleroma.FollowingRelationship
   alias Pleroma.Maps
   alias Pleroma.Notification
@@ -18,7 +19,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Builder
   alias Pleroma.Web.ActivityPub.ObjectValidator
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types
   alias Pleroma.Web.ActivityPub.Pipeline
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
@@ -725,7 +725,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     else
       {:error, {:validate_object, _}} = e ->
         # Check if we have a create activity for this
-        with {:ok, object_id} <- Types.ObjectID.cast(data["object"]),
+        with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]),
              %Activity{data: %{"actor" => actor}} <-
                Activity.create_by_object_ap_id(object_id) |> Repo.one(),
              # We have one, insert a tombstone and retry
index 3e17a94974310fcfe791db716163686aa836dd74..43be8e9368cb770ab5aab5b9848227eaca838b24 100644 (file)
@@ -1,5 +1,5 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.DateTimeTest do
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.DateTime
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime
   use Pleroma.DataCase
 
   test "it validates an xsd:Datetime" do
index c8911948e7379e8f25e3a4c33df0f3e79800aa36..e0ab7637944e522638ed5eb5a10b7906db7d69c2 100644 (file)
@@ -3,7 +3,7 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ObjectValidators.Types.ObjectIDTest do
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
   use Pleroma.DataCase
 
   @uris [
index f278f039bb92b27f33a7ea314cc628b638e56848..053916bdd5f573875a375917b9b3641c61edf958 100644 (file)
@@ -1,5 +1,5 @@
 defmodule Pleroma.Web.ObjectValidators.Types.RecipientsTest do
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.Recipients
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.Recipients
   use Pleroma.DataCase
 
   test "it asserts that all elements of the list are object ids" do
index d4a574554b03c3389b4f57b5980064174f6a4d11..9c08606f6419aed0d164108685ba21838f3482f3 100644 (file)
@@ -5,7 +5,7 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do
   use Pleroma.DataCase
 
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeText
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.SafeText
 
   test "it lets normal text go through" do
     text = "hey how are you"