1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 16:33:28 +00:00
mobilizon/lib/graphql/resolvers/users/activity_settings.ex
Thomas Citharel b5d9b82bdd
Refactor Mobilizon.Federation.ActivityPub and add typespecs
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-09-29 16:31:11 +02:00

30 lines
1 KiB
Elixir

defmodule Mobilizon.GraphQL.Resolvers.Users.ActivitySettings do
@moduledoc """
Handles the user activity settings-related GraphQL calls.
"""
alias Mobilizon.Users
alias Mobilizon.Users.{ActivitySetting, User}
require Logger
@spec user_activity_settings(any(), map(), Absinthe.Resolution.t()) ::
{:ok, list(ActivitySetting.t())} | {:error, :unauthenticated}
def user_activity_settings(_parent, _args, %{context: %{current_user: %User{} = user}}) do
{:ok, Users.activity_settings_for_user(user)}
end
def user_activity_settings(_parent, _args, _context) do
{:error, :unauthenticated}
end
@spec upsert_user_activity_setting(any(), map(), Absinthe.Resolution.t()) ::
{:ok, ActivitySetting.t()} | {:error, :unauthenticated}
def upsert_user_activity_setting(_parent, args, %{context: %{current_user: %User{id: user_id}}}) do
Users.create_activity_setting(Map.put(args, :user_id, user_id))
end
def upsert_user_activity_setting(_parent, _args, _resolution) do
{:error, :unauthenticated}
end
end