import Ecto.Query
schema "conversation_participations" do
- belongs_to(:user, User, type: Pleroma.FlakeId)
+ belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
belongs_to(:conversation, Conversation)
field(:read, :boolean, default: false)
- field(:last_activity_id, Pleroma.FlakeId, virtual: true)
+ field(:last_activity_id, FlakeId.Ecto.CompatType, virtual: true)
has_many(:recipient_ships, RecipientShip)
has_many(:recipients, through: [:recipient_ships, :user])
|> Enum.filter(& &1.last_activity_id)
end
- def get(nil), do: nil
+ def get(_, _ \\ [])
+ def get(nil, _), do: nil
- def get(id) do
- Repo.get(__MODULE__, id)
+ def get(id, params) do
+ query =
+ if preload = params[:preload] do
+ from(p in __MODULE__,
+ preload: ^preload
+ )
+ else
+ __MODULE__
+ end
+
+ Repo.get(query, id)
end
def set_recipients(participation, user_ids) do