diff options
Diffstat (limited to 'lib/pleroma/activity.ex')
-rw-r--r-- | lib/pleroma/activity.ex | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 9a5e6fc78..d7e31b6b4 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -16,17 +16,22 @@ defmodule Pleroma.Activity do 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 from activity in Activity, - where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id)) + where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)), + where: fragment("(?)->>'type' = 'Create'", activity.data) end + # Wrong name, returns all. def all_non_create_by_object_ap_id_q(ap_id) do from activity in Activity, - where: fragment("(?)->>'object' = ?", activity.data, ^to_string(ap_id)) + where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)) end + # Wrong name plz fix thx def all_by_object_ap_id(ap_id) do Repo.all(all_by_object_ap_id_q(ap_id)) end |