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