Merge remote-tracking branch 'origin/develop' into remote-follow-api
[akkoma] / lib / pleroma / web / activity_pub / object_validators / create_generic_validator.ex
index 51d43e8d08f1ddcf1ac674630452ba335d060ae7..803b5d5a11d009b2752e871a29062701e919ac3f 100644 (file)
@@ -20,14 +20,14 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator do
   @primary_key false
 
   embedded_schema do
-    field(:id, ObjectValidators.ObjectID, primary_key: true)
-    field(:actor, ObjectValidators.ObjectID)
-    field(:type, :string)
-    field(:to, ObjectValidators.Recipients, default: [])
-    field(:cc, ObjectValidators.Recipients, default: [])
-    field(:bto, ObjectValidators.Recipients, default: [])
-    field(:bcc, ObjectValidators.Recipients, default: [])
-    field(:object, ObjectValidators.ObjectID)
+    quote do
+      unquote do
+        import Elixir.Pleroma.Web.ActivityPub.ObjectValidators.CommonFields
+        message_fields()
+        activity_fields()
+      end
+    end
+
     field(:expires_at, ObjectValidators.DateTime)
 
     # Should be moved to object, done for CommonAPI.Utils.make_context
@@ -63,11 +63,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator do
     %User{follower_address: follower_collection} = User.get_cached_by_ap_id(data["actor"])
 
     data
-    |> CommonFixes.cast_recipients("to", object["to"])
-    |> CommonFixes.cast_recipients("cc", object["cc"])
-    |> CommonFixes.cast_recipients("bto", object["bto"])
-    |> CommonFixes.cast_recipients("bcc", object["bcc"])
-    |> Transmogrifier.fix_explicit_addressing(follower_collection)
+    |> CommonFixes.cast_and_filter_recipients("to", follower_collection, object["to"])
+    |> CommonFixes.cast_and_filter_recipients("cc", follower_collection, object["cc"])
+    |> CommonFixes.cast_and_filter_recipients("bto", follower_collection, object["bto"])
+    |> CommonFixes.cast_and_filter_recipients("bcc", follower_collection, object["bcc"])
     |> Transmogrifier.fix_implicit_addressing(follower_collection)
   end