X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity.ex;h=66854dc2dd2920208261f4da1849420bd60c874a;hb=7daa9a8c42272e0f1fd0ac3af31e0cf131d86219;hp=81079ec3e64002f1b6eff8e3cd0638ca4f127208;hpb=98c8184c1fc013fbd48bd78a2603c8e560038081;p=akkoma diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 81079ec3e..66854dc2d 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -4,10 +4,15 @@ defmodule Pleroma.Activity do use Ecto.Schema - alias Pleroma.{Repo, Activity, Notification} + + alias Pleroma.Repo + alias Pleroma.Activity + alias Pleroma.Notification + import Ecto.Query @type t :: %__MODULE__{} + @primary_key {:id, Pleroma.FlakeId, autogenerate: true} # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19 @mastodon_notification_types %{ @@ -36,6 +41,10 @@ defmodule Pleroma.Activity do ) end + def get_by_id(id) do + Repo.get(Activity, id) + end + def by_object_ap_id(ap_id) do from( activity in Activity, @@ -49,7 +58,6 @@ defmodule Pleroma.Activity do ) end - def create_by_object_ap_id(ap_ids) when is_list(ap_ids) do from( activity in Activity, @@ -105,4 +113,14 @@ defmodule Pleroma.Activity do end def mastodon_notification_type(%Activity{}), do: nil + + def all_by_actor_and_id(actor, status_ids \\ []) + def all_by_actor_and_id(_actor, []), do: [] + + def all_by_actor_and_id(actor, status_ids) do + Activity + |> where([s], s.id in ^status_ids) + |> where([s], s.actor == ^actor) + |> Repo.all() + end end