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)))
19 # Wrong name, only returns create activities
20 def all_by_object_ap_id_q(ap_id) do
21 from activity in Activity,
22 where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
25 def all_non_create_by_object_ap_id_q(ap_id) do
26 from activity in Activity,
27 where: fragment("(?)->>'object' = ?", activity.data, ^to_string(ap_id))
30 def all_by_object_ap_id(ap_id) do
31 Repo.all(all_by_object_ap_id_q(ap_id))
34 def get_create_activity_by_object_ap_id(ap_id) do
35 Repo.one(from activity in Activity,
36 where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
37 and fragment("(?)->>'type' = 'Create'", activity.data))