projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix multi-after-transaction
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
object_validators
/
delete_validator.ex
diff --git
a/lib/pleroma/web/activity_pub/object_validators/delete_validator.ex
b/lib/pleroma/web/activity_pub/object_validators/delete_validator.ex
index fc1a79a729486baf040a011f46acd5374d87d66e..f0c99356e75aa3f54f773ce66b3cff37bafbe860 100644
(file)
--- a/
lib/pleroma/web/activity_pub/object_validators/delete_validator.ex
+++ b/
lib/pleroma/web/activity_pub/object_validators/delete_validator.ex
@@
-7,6
+7,7
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
alias Pleroma.Activity
alias Pleroma.EctoType.ActivityPub.ObjectValidators
alias Pleroma.Activity
alias Pleroma.EctoType.ActivityPub.ObjectValidators
+ alias Pleroma.User
import Ecto.Changeset
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
import Ecto.Changeset
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
@@
-14,13
+15,15
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
@primary_key false
embedded_schema do
@primary_key false
embedded_schema do
- field(:id, ObjectValidators.ObjectID, primary_key: true)
- field(:type, :string)
- field(:actor, ObjectValidators.ObjectID)
- field(:to, ObjectValidators.Recipients, default: [])
- field(:cc, ObjectValidators.Recipients, default: [])
+ quote do
+ unquote do
+ import Elixir.Pleroma.Web.ActivityPub.ObjectValidators.CommonFields
+ message_fields()
+ activity_fields()
+ end
+ end
+
field(:deleted_activity_id, ObjectValidators.ObjectID)
field(:deleted_activity_id, ObjectValidators.ObjectID)
- field(:object, ObjectValidators.ObjectID)
end
def cast_data(data) do
end
def cast_data(data) do
@@
-53,11
+56,11
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
Tombstone
Video
}
Tombstone
Video
}
- def validate_data(cng) do
+ def
p
validate_data(cng) do
cng
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|> validate_inclusion(:type, ["Delete"])
cng
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|> validate_inclusion(:type, ["Delete"])
- |> validate_
actor_presence(
)
+ |> validate_
delete_actor(:actor
)
|> validate_modification_rights()
|> validate_object_or_user_presence(allowed_types: @deletable_types)
|> add_deleted_activity_id()
|> validate_modification_rights()
|> validate_object_or_user_presence(allowed_types: @deletable_types)
|> add_deleted_activity_id()
@@
-72,4
+75,13
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
|> cast_data
|> validate_data
end
|> cast_data
|> validate_data
end
+
+ defp validate_delete_actor(cng, field_name) do
+ validate_change(cng, field_name, fn field_name, actor ->
+ case User.get_cached_by_ap_id(actor) do
+ %User{} -> []
+ _ -> [{field_name, "can't find user"}]
+ end
+ end)
+ end
end
end