Browse Source

Refactors.

debug-remote-ip
lain 4 years ago
parent
commit
eaacc64839
2 changed files with 4 additions and 5 deletions
  1. +1
    -2
      lib/pleroma/web/activity_pub/activity_pub.ex
  2. +3
    -3
      lib/pleroma/web/activity_pub/object_validators/common_validations.ex

+ 1
- 2
lib/pleroma/web/activity_pub/activity_pub.ex View File

@@ -125,8 +125,6 @@ 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
with local <- Keyword.fetch!(meta, :local),
@@ -142,6 +140,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
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),


+ 3
- 3
lib/pleroma/web/activity_pub/object_validators/common_validations.ex View File

@@ -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


Loading…
Cancel
Save