Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

39 řádky
1.1KB

  1. defmodule Pleroma.Activity do
  2. use Ecto.Schema
  3. alias Pleroma.{Repo, Activity}
  4. import Ecto.Query
  5. schema "activities" do
  6. field :data, :map
  7. field :local, :boolean, default: true
  8. timestamps()
  9. end
  10. def get_by_ap_id(ap_id) do
  11. Repo.one(from activity in Activity,
  12. where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
  13. end
  14. # Wrong name, only returns create activities
  15. def all_by_object_ap_id_q(ap_id) do
  16. from activity in Activity,
  17. where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
  18. end
  19. def all_non_create_by_object_ap_id_q(ap_id) do
  20. from activity in Activity,
  21. where: fragment("(?)->>'object' = ?", activity.data, ^to_string(ap_id))
  22. end
  23. def all_by_object_ap_id(ap_id) do
  24. Repo.all(all_by_object_ap_id_q(ap_id))
  25. end
  26. def get_create_activity_by_object_ap_id(ap_id) do
  27. Repo.one(from activity in Activity,
  28. where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
  29. and fragment("(?)->>'type' = 'Create'", activity.data))
  30. end
  31. end