1 defmodule Pleroma.Activity do
3 alias Pleroma.{Repo, Activity, Notification}
8 field :local, :boolean, default: true
9 has_many :notifications, Notification
14 def get_by_ap_id(ap_id) do
15 Repo.one(from activity in Activity,
16 where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
20 # Go through these and fix them everywhere.
21 # Wrong name, only returns create activities
22 def all_by_object_ap_id_q(ap_id) do
23 from activity in Activity,
24 where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)),
25 where: fragment("(?)->>'type' = 'Create'", activity.data)
28 # Wrong name, returns all.
29 def all_non_create_by_object_ap_id_q(ap_id) do
30 from activity in Activity,
31 where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id))
34 # Wrong name plz fix thx
35 def all_by_object_ap_id(ap_id) do
36 Repo.all(all_by_object_ap_id_q(ap_id))
39 def get_create_activity_by_object_ap_id(ap_id) do
40 Repo.one(from activity in Activity,
41 where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)),
42 where: fragment("(?)->>'type' = 'Create'", activity.data))