Various refactoring and typespec improvements

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-09-24 16:46:42 +02:00
parent d235653876
commit 1893d9f55b
142 changed files with 1854 additions and 1297 deletions

View File

@@ -31,7 +31,10 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
@doc """
Return current logged-in user
"""
def get_current_user(_parent, _args, %{context: %{current_user: %User{} = user}}) do
@spec get_current_user(any, map(), Absinthe.Resolution.t()) ::
{:error, :unauthenticated} | {:ok, Mobilizon.Users.User.t()}
def get_current_user(_parent, _args, %{context: %{current_user: %User{} = user} = context}) do
# Logger.error(inspect(context))
{:ok, user}
end
@@ -199,7 +202,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
@doc """
Validate an user, get its actor and a token
"""
@spec validate_user(map(), %{token: String.t()}, map()) :: {:ok, map()}
@spec validate_user(map(), %{token: String.t()}, map()) :: {:ok, map()} | {:error, String.t()}
def validate_user(_parent, %{token: token}, _resolution) do
with {:check_confirmation_token, {:ok, %User{} = user}} <-
{:check_confirmation_token, Email.User.check_confirmation_token(token)},