2021-02-24 19:06:48 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.ActivityType do
|
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Activity
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
|
|
|
|
alias Mobilizon.Actors.{Actor, Member}
|
2021-03-10 17:38:13 +01:00
|
|
|
alias Mobilizon.Discussions.{Comment, Discussion}
|
2021-02-24 19:06:48 +01:00
|
|
|
alias Mobilizon.Events.Event
|
|
|
|
alias Mobilizon.Posts.Post
|
|
|
|
alias Mobilizon.Resources.Resource
|
|
|
|
|
|
|
|
enum :activity_type do
|
|
|
|
value(:event, description: "Activities concerning events")
|
|
|
|
value(:post, description: "Activities concerning posts")
|
|
|
|
value(:discussion, description: "Activities concerning discussions")
|
|
|
|
value(:resource, description: "Activities concerning resources")
|
|
|
|
value(:group, description: "Activities concerning group settings")
|
|
|
|
value(:member, description: "Activities concerning members")
|
|
|
|
end
|
|
|
|
|
2021-03-09 16:20:58 +01:00
|
|
|
enum :activity_author do
|
|
|
|
value(:self, description: "Activities created by the current actor")
|
|
|
|
value(:by, description: "Activities created by others")
|
|
|
|
end
|
|
|
|
|
2021-02-24 19:06:48 +01:00
|
|
|
object :activity_param_item do
|
|
|
|
field(:key, :string)
|
|
|
|
field(:value, :string)
|
|
|
|
end
|
|
|
|
|
|
|
|
interface :activity_object do
|
|
|
|
field(:id, :id)
|
|
|
|
|
|
|
|
resolve_type(fn
|
|
|
|
%Event{}, _ ->
|
|
|
|
:event
|
|
|
|
|
|
|
|
%Post{}, _ ->
|
|
|
|
:post
|
|
|
|
|
|
|
|
%Actor{type: "Group"}, _ ->
|
|
|
|
:group
|
|
|
|
|
|
|
|
%Member{}, _ ->
|
|
|
|
:member
|
|
|
|
|
|
|
|
%Resource{}, _ ->
|
|
|
|
:resource
|
|
|
|
|
|
|
|
%Discussion{}, _ ->
|
|
|
|
:discussion
|
|
|
|
|
2021-03-10 17:38:13 +01:00
|
|
|
%Comment{}, _ ->
|
|
|
|
:comment
|
|
|
|
|
2021-02-24 19:06:48 +01:00
|
|
|
%Actor{type: :Group}, _ ->
|
|
|
|
:group
|
|
|
|
|
|
|
|
_, _ ->
|
|
|
|
nil
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
A paginated list of activity items
|
|
|
|
"""
|
|
|
|
object :paginated_activity_list do
|
|
|
|
field(:elements, list_of(:activity), description: "A list of activities")
|
|
|
|
field(:total, :integer, description: "The total number of elements in the list")
|
|
|
|
end
|
|
|
|
|
|
|
|
object :activity do
|
|
|
|
field(:id, :id, description: "The activity item ID")
|
|
|
|
field(:inserted_at, :datetime, description: "When was the activity inserted")
|
|
|
|
field(:priority, :integer)
|
|
|
|
field(:type, :activity_type)
|
|
|
|
field(:subject, :string)
|
|
|
|
field(:subject_params, list_of(:activity_param_item))
|
|
|
|
field(:message, :string)
|
|
|
|
field(:message_params, list_of(:activity_param_item))
|
|
|
|
field(:object, :activity_object)
|
|
|
|
field(:author, :actor)
|
|
|
|
field(:group, :group)
|
|
|
|
end
|
|
|
|
end
|