projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
activitypub: utils: also match Activity objects
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
activity_pub.ex
diff --git
a/lib/pleroma/web/activity_pub/activity_pub.ex
b/lib/pleroma/web/activity_pub/activity_pub.ex
index adb42b9abe6c2c2f5b6e2a16627a88fdac570285..70db419cad6cf400b92efb3d2fc1ea2a69e05634 100644
(file)
--- a/
lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/
lib/pleroma/web/activity_pub/activity_pub.ex
@@
-4,17
+4,17
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
alias Pleroma.Activity
defmodule Pleroma.Web.ActivityPub.ActivityPub do
alias Pleroma.Activity
- alias Pleroma.Repo
+ alias Pleroma.Instances
+ alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Object
+ alias Pleroma.Repo
alias Pleroma.Upload
alias Pleroma.User
alias Pleroma.Upload
alias Pleroma.User
- alias Pleroma.Notification
- alias Pleroma.Instances
- alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.MRF
- alias Pleroma.Web.
WebFing
er
+ alias Pleroma.Web.
ActivityPub.Transmogrifi
er
alias Pleroma.Web.Federator
alias Pleroma.Web.OStatus
alias Pleroma.Web.Federator
alias Pleroma.Web.OStatus
+ alias Pleroma.Web.WebFinger
import Ecto.Query
import Pleroma.Web.ActivityPub.Utils
import Ecto.Query
import Pleroma.Web.ActivityPub.Utils
@@
-170,7
+170,8
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
additional
),
{:ok, activity} <- insert(create_data, local),
additional
),
{:ok, activity} <- insert(create_data, local),
- # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+ # Changing note count prior to enqueuing federation task in order to avoid
+ # race conditions on updating user.info
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
@@
-309,18
+310,19
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ true) do
user = User.get_cached_by_ap_id(actor)
def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ true) do
user = User.get_cached_by_ap_id(actor)
- to = object.data["to"] || [] ++ object.data["cc"] || []
-
- data = %{
- "type" => "Delete",
- "actor" => actor,
- "object" => id,
- "to" => to
- }
+ to = (object.data["to"] || []) ++ (object.data["cc"] || [])
- with {:ok, _} <- Object.delete(object),
+ with {:ok, object, activity} <- Object.delete(object),
+ data <- %{
+ "type" => "Delete",
+ "actor" => actor,
+ "object" => id,
+ "to" => to,
+ "deleted_activity_id" => activity && activity.id
+ },
{:ok, activity} <- insert(data, local),
{:ok, activity} <- insert(data, local),
- # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+ # Changing note count prior to enqueuing federation task in order to avoid
+ # race conditions on updating user.info
{:ok, _actor} <- decrease_note_count_if_public(user, object),
:ok <- maybe_federate(activity) do
{:ok, activity}
{:ok, _actor} <- decrease_note_count_if_public(user, object),
:ok <- maybe_federate(activity) do
{:ok, activity}
@@
-502,7
+504,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
when is_list(tag_reject) and tag_reject != [] do
from(
activity in query,
when is_list(tag_reject) and tag_reject != [] do
from(
activity in query,
- where: fragment(
"(not (? #> '{\"object\",\"tag\"}') \\?| ?)"
, activity.data, ^tag_reject)
+ where: fragment(
~s(\(not \(? #> '{"object","tag"}'\) \\?| ?\))
, activity.data, ^tag_reject)
)
end
)
end
@@
-512,7
+514,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
when is_list(tag_all) and tag_all != [] do
from(
activity in query,
when is_list(tag_all) and tag_all != [] do
from(
activity in query,
- where: fragment(
"(? #> '{\"object\",\"tag\"}') \\?& ?"
, activity.data, ^tag_all)
+ where: fragment(
~s(\(? #> '{"object","tag"}'\) \\?& ?)
, activity.data, ^tag_all)
)
end
)
end
@@
-521,14
+523,14
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_tag(query, %{"tag" => tag}) when is_list(tag) do
from(
activity in query,
defp restrict_tag(query, %{"tag" => tag}) when is_list(tag) do
from(
activity in query,
- where: fragment(
"(? #> '{\"object\",\"tag\"}') \\?| ?"
, activity.data, ^tag)
+ where: fragment(
~s(\(? #> '{"object","tag"}'\) \\?| ?)
, activity.data, ^tag)
)
end
defp restrict_tag(query, %{"tag" => tag}) when is_binary(tag) do
from(
activity in query,
)
end
defp restrict_tag(query, %{"tag" => tag}) when is_binary(tag) do
from(
activity in query,
- where: fragment(
"? <@ (? #> '{\"object\",\"tag\"}')"
, ^tag, activity.data)
+ where: fragment(
~s(? <@ (? #> '{"object","tag"}'\))
, ^tag, activity.data)
)
end
)
end
@@
-601,7
+603,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_favorited_by(query, %{"favorited_by" => ap_id}) do
from(
activity in query,
defp restrict_favorited_by(query, %{"favorited_by" => ap_id}) do
from(
activity in query,
- where: fragment(
"? <@ (? #> '{\"object\",\"likes\"}')"
, ^ap_id, activity.data)
+ where: fragment(
~s(? <@ (? #> '{"object","likes"}'\))
, ^ap_id, activity.data)
)
end
)
end
@@
-610,7
+612,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp restrict_media(query, %{"only_media" => val}) when val == "true" or val == "1" do
from(
activity in query,
defp restrict_media(query, %{"only_media" => val}) when val == "true" or val == "1" do
from(
activity in query,
- where: fragment(
"not (? #> '{\"object\",\"attachment\"}' = ?)"
, activity.data, ^[])
+ where: fragment(
~s(not (? #> '{"object","attachment"}' = ?\))
, activity.data, ^[])
)
end
)
end