FlakeId.Ecto.CompatType.t() does not exist

This type is not exported and usable. FlakeId intends to return the type as :uuid, so we replace it in the typespecs with Ecto.UUID.t() which assuages the dialyzer errors

e.g.,

lib/pleroma/bookmark.ex:25:unknown_type
Unknown type: FlakeId.Ecto.CompatType.t/0.
This commit is contained in:
Mark Felder 2024-01-20 16:36:01 -05:00
parent b16a01ba9d
commit dc8045d766
4 changed files with 12 additions and 12 deletions

View File

@ -22,7 +22,7 @@ defmodule Pleroma.Bookmark do
timestamps() timestamps()
end end
@spec create(FlakeId.Ecto.CompatType.t(), FlakeId.Ecto.CompatType.t()) :: @spec create(Ecto.UUID.t(), Ecto.UUID.t()) ::
{:ok, Bookmark.t()} | {:error, Changeset.t()} {:ok, Bookmark.t()} | {:error, Changeset.t()}
def create(user_id, activity_id) do def create(user_id, activity_id) do
attrs = %{ attrs = %{
@ -37,7 +37,7 @@ defmodule Pleroma.Bookmark do
|> Repo.insert() |> Repo.insert()
end end
@spec for_user_query(FlakeId.Ecto.CompatType.t()) :: Ecto.Query.t() @spec for_user_query(Ecto.UUID.t()) :: Ecto.Query.t()
def for_user_query(user_id) do def for_user_query(user_id) do
Bookmark Bookmark
|> where(user_id: ^user_id) |> where(user_id: ^user_id)
@ -52,7 +52,7 @@ defmodule Pleroma.Bookmark do
|> Repo.one() |> Repo.one()
end end
@spec destroy(FlakeId.Ecto.CompatType.t(), FlakeId.Ecto.CompatType.t()) :: @spec destroy(Ecto.UUID.t(), Ecto.UUID.t()) ::
{:ok, Bookmark.t()} | {:error, Changeset.t()} {:ok, Bookmark.t()} | {:error, Changeset.t()}
def destroy(user_id, activity_id) do def destroy(user_id, activity_id) do
from(b in Bookmark, from(b in Bookmark,

View File

@ -42,7 +42,7 @@ defmodule Pleroma.Chat do
|> unique_constraint(:user_id, name: :chats_user_id_recipient_index) |> unique_constraint(:user_id, name: :chats_user_id_recipient_index)
end end
@spec get_by_user_and_id(User.t(), FlakeId.Ecto.CompatType.t()) :: @spec get_by_user_and_id(User.t(), Ecto.UUID.t()) ::
{:ok, t()} | {:error, :not_found} {:ok, t()} | {:error, :not_found}
def get_by_user_and_id(%User{id: user_id}, id) do def get_by_user_and_id(%User{id: user_id}, id) do
from(c in __MODULE__, from(c in __MODULE__,
@ -52,17 +52,17 @@ defmodule Pleroma.Chat do
|> Repo.find_resource() |> Repo.find_resource()
end end
@spec get_by_id(FlakeId.Ecto.CompatType.t()) :: t() | nil @spec get_by_id(Ecto.UUID.t()) :: t() | nil
def get_by_id(id) do def get_by_id(id) do
Repo.get(__MODULE__, id) Repo.get(__MODULE__, id)
end end
@spec get(FlakeId.Ecto.CompatType.t(), String.t()) :: t() | nil @spec get(Ecto.UUID.t(), String.t()) :: t() | nil
def get(user_id, recipient) do def get(user_id, recipient) do
Repo.get_by(__MODULE__, user_id: user_id, recipient: recipient) Repo.get_by(__MODULE__, user_id: user_id, recipient: recipient)
end end
@spec get_or_create(FlakeId.Ecto.CompatType.t(), String.t()) :: @spec get_or_create(Ecto.UUID.t(), String.t()) ::
{:ok, t()} | {:error, Ecto.Changeset.t()} {:ok, t()} | {:error, Ecto.Changeset.t()}
def get_or_create(user_id, recipient) do def get_or_create(user_id, recipient) do
%__MODULE__{} %__MODULE__{}
@ -75,7 +75,7 @@ defmodule Pleroma.Chat do
) )
end end
@spec bump_or_create(FlakeId.Ecto.CompatType.t(), String.t()) :: @spec bump_or_create(Ecto.UUID.t(), String.t()) ::
{:ok, t()} | {:error, Ecto.Changeset.t()} {:ok, t()} | {:error, Ecto.Changeset.t()}
def bump_or_create(user_id, recipient) do def bump_or_create(user_id, recipient) do
%__MODULE__{} %__MODULE__{}
@ -87,7 +87,7 @@ defmodule Pleroma.Chat do
) )
end end
@spec for_user_query(FlakeId.Ecto.CompatType.t()) :: Ecto.Query.t() @spec for_user_query(Ecto.UUID.t()) :: Ecto.Query.t()
def for_user_query(user_id) do def for_user_query(user_id) do
from(c in Chat, from(c in Chat,
where: c.user_id == ^user_id, where: c.user_id == ^user_id,

View File

@ -23,7 +23,7 @@ defmodule Pleroma.ReportNote do
timestamps() timestamps()
end end
@spec create(FlakeId.Ecto.CompatType.t(), FlakeId.Ecto.CompatType.t(), String.t()) :: @spec create(Ecto.UUID.t(), Ecto.UUID.t(), String.t()) ::
{:ok, ReportNote.t()} | {:error, Changeset.t()} {:ok, ReportNote.t()} | {:error, Changeset.t()}
def create(user_id, activity_id, content) do def create(user_id, activity_id, content) do
attrs = %{ attrs = %{
@ -38,7 +38,7 @@ defmodule Pleroma.ReportNote do
|> Repo.insert() |> Repo.insert()
end end
@spec destroy(FlakeId.Ecto.CompatType.t()) :: @spec destroy(Ecto.UUID.t()) ::
{:ok, ReportNote.t()} | {:error, Changeset.t()} {:ok, ReportNote.t()} | {:error, Changeset.t()}
def destroy(id) do def destroy(id) do
from(r in ReportNote, where: r.id == ^id) from(r in ReportNote, where: r.id == ^id)

View File

@ -499,7 +499,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end end
@spec fetch_latest_direct_activity_id_for_context(String.t(), keyword() | map()) :: @spec fetch_latest_direct_activity_id_for_context(String.t(), keyword() | map()) ::
FlakeId.Ecto.CompatType.t() | nil Ecto.UUID.t() | nil
def fetch_latest_direct_activity_id_for_context(context, opts \\ %{}) do def fetch_latest_direct_activity_id_for_context(context, opts \\ %{}) do
context context
|> fetch_activities_for_context_query(Map.merge(%{skip_preload: true}, opts)) |> fetch_activities_for_context_query(Map.merge(%{skip_preload: true}, opts))