Handle webpubs in queue.
[akkoma] / lib / pleroma / activity.ex
1 defmodule Pleroma.Activity do
2 use Ecto.Schema
3 alias Pleroma.{Repo, Activity}
4 import Ecto.Query
5
6 schema "activities" do
7 field :data, :map
8 field :local, :boolean, default: true
9
10 timestamps()
11 end
12
13 def get_by_ap_id(ap_id) do
14 Repo.one(from activity in Activity,
15 where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
16 end
17
18 def all_by_object_ap_id(ap_id) do
19 Repo.all(from activity in Activity,
20 where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id)))
21 end
22
23 def get_create_activity_by_object_ap_id(ap_id) do
24 Repo.one(from activity in Activity,
25 where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
26 and fragment("(?)->>'type' = 'Create'", activity.data))
27 end
28 end