WIP notification settings
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
26
lib/graphql/resolvers/users/activity_settings.ex
Normal file
26
lib/graphql/resolvers/users/activity_settings.ex
Normal file
@@ -0,0 +1,26 @@
|
||||
defmodule Mobilizon.GraphQL.Resolvers.Users.ActivitySettings do
|
||||
@moduledoc """
|
||||
Handles the user activity settings-related GraphQL calls.
|
||||
"""
|
||||
|
||||
alias Mobilizon.Users
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
require Logger
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
@@ -48,6 +48,7 @@ defmodule Mobilizon.GraphQL.Schema do
|
||||
import_types(Schema.AdminType)
|
||||
import_types(Schema.StatisticsType)
|
||||
import_types(Schema.Users.PushSubscription)
|
||||
import_types(Schema.Users.ActivitySetting)
|
||||
|
||||
@desc "A struct containing the id of the deleted object"
|
||||
object :deleted_object do
|
||||
@@ -182,6 +183,7 @@ defmodule Mobilizon.GraphQL.Schema do
|
||||
import_fields(:actor_mutations)
|
||||
import_fields(:follower_mutations)
|
||||
import_fields(:push_mutations)
|
||||
import_fields(:activity_setting_mutations)
|
||||
end
|
||||
|
||||
@desc """
|
||||
|
||||
@@ -50,6 +50,10 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
field(:updated_at, :datetime, description: "When was the comment updated")
|
||||
field(:deleted_at, :datetime, description: "When was the comment deleted")
|
||||
field(:published_at, :datetime, description: "When was the comment published")
|
||||
|
||||
field(:is_announcement, non_null(:boolean),
|
||||
description: "Whether this comment needs to be announced to participants"
|
||||
)
|
||||
end
|
||||
|
||||
@desc "The list of visibility options for a comment"
|
||||
@@ -86,6 +90,8 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
arg(:event_id, non_null(:id), description: "The event under which this comment is")
|
||||
arg(:in_reply_to_comment_id, :id, description: "The comment ID this one replies to")
|
||||
|
||||
arg(:is_announcement, :boolean, description: "Should this comment be announced to everyone?")
|
||||
|
||||
resolve(&Comment.create_comment/3)
|
||||
end
|
||||
|
||||
@@ -94,6 +100,8 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
arg(:text, non_null(:string), description: "The comment updated body")
|
||||
arg(:comment_id, non_null(:id), description: "The comment ID")
|
||||
|
||||
arg(:is_announcement, :boolean, description: "Should this comment be announced to everyone?")
|
||||
|
||||
resolve(&Comment.update_comment/3)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.GraphQL.Resolvers.{Media, User}
|
||||
alias Mobilizon.GraphQL.Resolvers.Users.ActivitySettings
|
||||
alias Mobilizon.GraphQL.Schema
|
||||
|
||||
import_types(Schema.SortType)
|
||||
@@ -131,6 +132,11 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||
resolve: &Media.user_size/3,
|
||||
description: "The total size of all the media from this user (from all their actors)"
|
||||
)
|
||||
|
||||
field(:activity_settings, list_of(:activity_setting),
|
||||
resolve: &ActivitySettings.user_activity_settings/3,
|
||||
description: "The user's activity settings"
|
||||
)
|
||||
end
|
||||
|
||||
@desc "The list of roles an user can have"
|
||||
|
||||
23
lib/graphql/schema/users/activity_setting.ex
Normal file
23
lib/graphql/schema/users/activity_setting.ex
Normal file
@@ -0,0 +1,23 @@
|
||||
defmodule Mobilizon.GraphQL.Schema.Users.ActivitySetting do
|
||||
@moduledoc """
|
||||
Schema representation for PushSubscription
|
||||
"""
|
||||
use Absinthe.Schema.Notation
|
||||
alias Mobilizon.GraphQL.Resolvers.Users.ActivitySettings
|
||||
|
||||
object :activity_setting do
|
||||
field(:key, :string)
|
||||
field(:method, :string)
|
||||
field(:enabled, :boolean)
|
||||
field(:user, :user)
|
||||
end
|
||||
|
||||
object :activity_setting_mutations do
|
||||
field :update_activity_setting, :activity_setting do
|
||||
arg(:key, non_null(:string))
|
||||
arg(:method, non_null(:string))
|
||||
arg(:enabled, non_null(:boolean))
|
||||
resolve(&ActivitySettings.upsert_user_activity_setting/3)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user