Add admin dashboard, event reporting, moderation report screens, moderation log
Close #156 and #158 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -13,7 +13,7 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
|
||||
@desc "An ActivityPub actor"
|
||||
interface :actor do
|
||||
field(:id, :integer, description: "Internal ID for this actor")
|
||||
field(:id, :id, description: "Internal ID for this actor")
|
||||
field(:url, :string, description: "The ActivityPub actor's URL")
|
||||
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
||||
field(:name, :string, description: "The actor's displayed name")
|
||||
|
||||
@@ -14,7 +14,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
object :group do
|
||||
interfaces([:actor])
|
||||
|
||||
field(:id, :integer, description: "Internal ID for this group")
|
||||
field(:id, :id, description: "Internal ID for this group")
|
||||
field(:url, :string, description: "The ActivityPub actor's URL")
|
||||
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
||||
field(:name, :string, description: "The actor's displayed name")
|
||||
@@ -96,9 +96,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
field :create_group, :group do
|
||||
arg(:preferred_username, non_null(:string), description: "The name for the group")
|
||||
|
||||
arg(:creator_actor_id, non_null(:integer),
|
||||
description: "The identity that creates the group"
|
||||
)
|
||||
arg(:creator_actor_id, non_null(:id), description: "The identity that creates the group")
|
||||
|
||||
arg(:name, :string, description: "The displayed name for the group")
|
||||
arg(:summary, :string, description: "The summary for the group", default_value: "")
|
||||
@@ -118,8 +116,8 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
|
||||
@desc "Delete a group"
|
||||
field :delete_group, :deleted_object do
|
||||
arg(:group_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:group_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Group.delete_group/3)
|
||||
end
|
||||
|
||||
@@ -24,16 +24,16 @@ defmodule MobilizonWeb.Schema.Actors.MemberType do
|
||||
object :member_mutations do
|
||||
@desc "Join a group"
|
||||
field :join_group, :member do
|
||||
arg(:group_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:group_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Resolvers.Group.join_group/3)
|
||||
end
|
||||
|
||||
@desc "Leave an event"
|
||||
field :leave_group, :deleted_member do
|
||||
arg(:group_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:group_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Resolvers.Group.leave_group/3)
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
"""
|
||||
object :person do
|
||||
interfaces([:actor])
|
||||
field(:id, :integer, description: "Internal ID for this person")
|
||||
field(:id, :id, description: "Internal ID for this person")
|
||||
field(:user, :user, description: "The user this actor is associated to")
|
||||
|
||||
field(:member_of, list_of(:member), description: "The list of groups this person is member of")
|
||||
|
||||
@@ -15,7 +15,7 @@ defmodule MobilizonWeb.Schema.AddressType do
|
||||
field(:country, :string)
|
||||
field(:description, :string)
|
||||
field(:url, :string)
|
||||
field(:id, :integer)
|
||||
field(:id, :id)
|
||||
field(:origin_id, :string)
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ defmodule MobilizonWeb.Schema.AddressType do
|
||||
field(:country, :string)
|
||||
field(:description, :string)
|
||||
field(:url, :string)
|
||||
field(:id, :integer)
|
||||
field(:id, :id)
|
||||
field(:origin_id, :string)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,13 +5,25 @@ defmodule MobilizonWeb.Schema.AdminType do
|
||||
use Absinthe.Schema.Notation
|
||||
alias MobilizonWeb.Resolvers.Admin
|
||||
alias Mobilizon.Reports.{Report, Note}
|
||||
alias Mobilizon.Events.Event
|
||||
|
||||
@desc "An action log"
|
||||
object :action_log do
|
||||
field(:id, :id, description: "Internal ID for this comment")
|
||||
field(:actor, :actor, description: "The actor that acted")
|
||||
field(:object, :action_log_object, description: "The object that was acted upon")
|
||||
field(:action, :string, description: "The action that was done")
|
||||
field(:action, :action_log_action, description: "The action that was done")
|
||||
field(:inserted_at, :datetime, description: "The time when the action was performed")
|
||||
end
|
||||
|
||||
enum :action_log_action do
|
||||
value(:report_update_closed)
|
||||
value(:report_update_opened)
|
||||
value(:report_update_resolved)
|
||||
value(:note_creation)
|
||||
value(:note_deletion)
|
||||
value(:event_deletion)
|
||||
value(:event_update)
|
||||
end
|
||||
|
||||
@desc "The objects that can be in an action log"
|
||||
@@ -25,11 +37,22 @@ defmodule MobilizonWeb.Schema.AdminType do
|
||||
%Note{}, _ ->
|
||||
:report_note
|
||||
|
||||
%Event{}, _ ->
|
||||
:event
|
||||
|
||||
_, _ ->
|
||||
nil
|
||||
end)
|
||||
end
|
||||
|
||||
object :dashboard do
|
||||
field(:last_public_event_published, :event, description: "Last public event publish")
|
||||
field(:number_of_users, :integer, description: "The number of local users")
|
||||
field(:number_of_events, :integer, description: "The number of local events")
|
||||
field(:number_of_comments, :integer, description: "The number of local comments")
|
||||
field(:number_of_reports, :integer, description: "The number of current opened reports")
|
||||
end
|
||||
|
||||
object :admin_queries do
|
||||
@desc "Get the list of action logs"
|
||||
field :action_logs, type: list_of(:action_log) do
|
||||
@@ -37,5 +60,9 @@ defmodule MobilizonWeb.Schema.AdminType do
|
||||
arg(:limit, :integer, default_value: 10)
|
||||
resolve(&Admin.list_action_logs/3)
|
||||
end
|
||||
|
||||
field :dashboard, type: :dashboard do
|
||||
resolve(&Admin.get_dashboard/3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
|
||||
@desc "An event"
|
||||
object :event do
|
||||
field(:id, :integer, description: "Internal ID for this event")
|
||||
interfaces([:action_log_object])
|
||||
field(:id, :id, description: "Internal ID for this event")
|
||||
field(:uuid, :uuid, description: "The Event UUID")
|
||||
field(:url, :string, description: "The ActivityPub Event URL")
|
||||
field(:local, :boolean, description: "Whether the event is local or not")
|
||||
@@ -261,8 +262,8 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
|
||||
@desc "Delete an event"
|
||||
field :delete_event, :deleted_object do
|
||||
arg(:event_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:event_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Event.delete_event/3)
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ defmodule MobilizonWeb.Schema.Events.FeedTokenType do
|
||||
object :feed_token_mutations do
|
||||
@desc "Create a Feed Token"
|
||||
field :create_feed_token, :feed_token do
|
||||
arg(:actor_id, :integer)
|
||||
arg(:actor_id, :id)
|
||||
|
||||
resolve(&Resolvers.FeedToken.create_feed_token/3)
|
||||
end
|
||||
|
||||
@@ -46,16 +46,16 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
||||
object :participant_mutations do
|
||||
@desc "Join an event"
|
||||
field :join_event, :participant do
|
||||
arg(:event_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:event_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Resolvers.Event.actor_join_event/3)
|
||||
end
|
||||
|
||||
@desc "Leave an event"
|
||||
field :leave_event, :deleted_participant do
|
||||
arg(:event_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
arg(:event_id, non_null(:id))
|
||||
arg(:actor_id, non_null(:id))
|
||||
|
||||
resolve(&Resolvers.Event.actor_leave_event/3)
|
||||
end
|
||||
|
||||
@@ -3,6 +3,8 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
Schema representation for User
|
||||
"""
|
||||
use Absinthe.Schema.Notation
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
alias Mobilizon.Reports
|
||||
|
||||
alias MobilizonWeb.Resolvers.Report
|
||||
|
||||
@@ -17,6 +19,14 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
field(:reporter, :actor, description: "The actor that created the report")
|
||||
field(:event, :event, description: "The event that is being reported")
|
||||
field(:comments, list_of(:comment), description: "The comments that are reported")
|
||||
|
||||
field(:notes, list_of(:report_note),
|
||||
description: "The notes made on the event",
|
||||
resolve: dataloader(Reports)
|
||||
)
|
||||
|
||||
field(:inserted_at, :datetime, description: "When the report was created")
|
||||
field(:updated_at, :datetime, description: "When the report was updated")
|
||||
end
|
||||
|
||||
@desc "A report note object"
|
||||
@@ -24,8 +34,14 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
interfaces([:action_log_object])
|
||||
field(:id, :id, description: "The internal ID of the report note")
|
||||
field(:content, :string, description: "The content of the note")
|
||||
field(:moderator, :actor, description: "The moderator who added the note")
|
||||
|
||||
field(:moderator, :actor,
|
||||
description: "The moderator who added the note",
|
||||
resolve: dataloader(Reports)
|
||||
)
|
||||
|
||||
field(:report, :report, description: "The report on which this note is added")
|
||||
field(:inserted_at, :datetime, description: "When the report note was created")
|
||||
end
|
||||
|
||||
@desc "The list of possible statuses for a report object"
|
||||
@@ -40,6 +56,7 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
field :reports, list_of(:report) do
|
||||
arg(:page, :integer, default_value: 1)
|
||||
arg(:limit, :integer, default_value: 10)
|
||||
arg(:status, :report_status, default_value: :open)
|
||||
resolve(&Report.list_reports/3)
|
||||
end
|
||||
|
||||
@@ -53,7 +70,7 @@ defmodule MobilizonWeb.Schema.ReportType do
|
||||
object :report_mutations do
|
||||
@desc "Create a report"
|
||||
field :create_report, type: :report do
|
||||
arg(:report_content, :string)
|
||||
arg(:content, :string)
|
||||
arg(:reporter_actor_id, non_null(:id))
|
||||
arg(:reported_actor_id, non_null(:id))
|
||||
arg(:event_id, :id, default_value: nil)
|
||||
|
||||
@@ -43,6 +43,14 @@ defmodule MobilizonWeb.Schema.UserType do
|
||||
resolve: dataloader(Events),
|
||||
description: "A list of the feed tokens for this user"
|
||||
)
|
||||
|
||||
field(:role, :user_role, description: "The role for the user")
|
||||
end
|
||||
|
||||
enum :user_role do
|
||||
value(:administrator)
|
||||
value(:moderator)
|
||||
value(:user)
|
||||
end
|
||||
|
||||
@desc "Token"
|
||||
|
||||
Reference in New Issue
Block a user