projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into develop
[akkoma]
/
lib
/
pleroma
/
activity.ex
diff --git
a/lib/pleroma/activity.ex
b/lib/pleroma/activity.ex
index a35ccc9b415cff3ab73cb21c8f852b55a9cccdc1..c7502981e31be64eac7e478750537dc772280ea4 100644
(file)
--- a/
lib/pleroma/activity.ex
+++ b/
lib/pleroma/activity.ex
@@
-4,32
+4,53
@@
defmodule Pleroma.Activity do
import Ecto.Query
schema "activities" do
import Ecto.Query
schema "activities" do
- field :data, :map
- field :local, :boolean, default: true
- field :actor, :string
- has_many :notifications, Notification
+ field(:data, :map)
+ field(:local, :boolean, default: true)
+ field(:actor, :string)
+ field(:recipients, {:array, :string})
+ has_many(:notifications, Notification, on_delete: :delete_all)
timestamps()
end
def get_by_ap_id(ap_id) do
timestamps()
end
def get_by_ap_id(ap_id) do
- Repo.one(from activity in Activity,
- where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
+ Repo.one(
+ from(
+ activity in Activity,
+ where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id))
+ )
+ )
end
# TODO:
# Go through these and fix them everywhere.
# Wrong name, only returns create activities
def all_by_object_ap_id_q(ap_id) do
end
# TODO:
# Go through these and fix them everywhere.
# Wrong name, only returns create activities
def all_by_object_ap_id_q(ap_id) do
- from activity in Activity,
- where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)),
+ from(
+ activity in Activity,
+ where:
+ fragment(
+ "coalesce((?)->'object'->>'id', (?)->>'object') = ?",
+ activity.data,
+ activity.data,
+ ^to_string(ap_id)
+ ),
where: fragment("(?)->>'type' = 'Create'", activity.data)
where: fragment("(?)->>'type' = 'Create'", activity.data)
+ )
end
# Wrong name, returns all.
def all_non_create_by_object_ap_id_q(ap_id) do
end
# Wrong name, returns all.
def all_non_create_by_object_ap_id_q(ap_id) do
- from activity in Activity,
- where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id))
+ from(
+ activity in Activity,
+ where:
+ fragment(
+ "coalesce((?)->'object'->>'id', (?)->>'object') = ?",
+ activity.data,
+ activity.data,
+ ^to_string(ap_id)
+ )
+ )
end
# Wrong name plz fix thx
end
# Wrong name plz fix thx
@@
-37,9
+58,22
@@
defmodule Pleroma.Activity do
Repo.all(all_by_object_ap_id_q(ap_id))
end
Repo.all(all_by_object_ap_id_q(ap_id))
end
+ def create_activity_by_object_id_query(ap_ids) do
+ from(
+ activity in Activity,
+ where:
+ fragment(
+ "coalesce((?)->'object'->>'id', (?)->>'object') = ANY(?)",
+ activity.data,
+ activity.data,
+ ^ap_ids
+ ),
+ where: fragment("(?)->>'type' = 'Create'", activity.data)
+ )
+ end
+
def get_create_activity_by_object_ap_id(ap_id) do
def get_create_activity_by_object_ap_id(ap_id) do
- Repo.one(from activity in Activity,
- where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)),
- where: fragment("(?)->>'type' = 'Create'", activity.data))
+ create_activity_by_object_id_query([ap_id])
+ |> Repo.one()
end
end
end
end