Refactor media upload
Use Upload Media logic from Pleroma Backend changes for picture upload Move AS <-> Model conversion to separate module Front changes Downgrade apollo-client: https://github.com/Akryum/vue-apollo/issues/577 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -5,10 +5,11 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
use Absinthe.Schema.Notation
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Events
|
||||
alias Mobilizon.{Events}
|
||||
|
||||
import_types(MobilizonWeb.Schema.Actors.FollowerType)
|
||||
import_types(MobilizonWeb.Schema.EventType)
|
||||
# import_types(MobilizonWeb.Schema.PictureType)
|
||||
|
||||
@desc "An ActivityPub actor"
|
||||
interface :actor do
|
||||
@@ -27,8 +28,9 @@ defmodule MobilizonWeb.Schema.ActorInterface do
|
||||
)
|
||||
|
||||
field(:suspended, :boolean, description: "If the actor is suspended")
|
||||
field(:avatar_url, :string, description: "The actor's avatar url")
|
||||
field(:banner_url, :string, description: "The actor's banner url")
|
||||
|
||||
field(:avatar, :picture, description: "The actor's avatar picture")
|
||||
field(:banner, :picture, description: "The actor's banner picture")
|
||||
|
||||
# These one should have a privacy setting
|
||||
field(:following, list_of(:follower), description: "List of followings")
|
||||
|
||||
@@ -5,7 +5,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
use Absinthe.Schema.Notation
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
import_types(MobilizonWeb.Schema.Actors.MemberType)
|
||||
alias MobilizonWeb.Resolvers
|
||||
alias MobilizonWeb.Resolvers.{Member, Group}
|
||||
alias Mobilizon.Events
|
||||
|
||||
@desc """
|
||||
@@ -29,8 +29,9 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
)
|
||||
|
||||
field(:suspended, :boolean, description: "If the actor is suspended")
|
||||
field(:avatar_url, :string, description: "The actor's avatar url")
|
||||
field(:banner_url, :string, description: "The actor's banner url")
|
||||
|
||||
field(:avatar, :picture, description: "The actor's avatar picture")
|
||||
field(:banner, :picture, description: "The actor's banner picture")
|
||||
|
||||
# These one should have a privacy setting
|
||||
field(:following, list_of(:follower), description: "List of followings")
|
||||
@@ -51,7 +52,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
)
|
||||
|
||||
field(:members, non_null(list_of(:member)),
|
||||
resolve: &Resolvers.Member.find_members_for_group/3,
|
||||
resolve: &Member.find_members_for_group/3,
|
||||
description: "List of group members"
|
||||
)
|
||||
end
|
||||
@@ -80,13 +81,13 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
field :groups, list_of(:group) do
|
||||
arg(:page, :integer, default_value: 1)
|
||||
arg(:limit, :integer, default_value: 10)
|
||||
resolve(&Resolvers.Group.list_groups/3)
|
||||
resolve(&Group.list_groups/3)
|
||||
end
|
||||
|
||||
@desc "Get a group by it's preferred username"
|
||||
field :group, :group do
|
||||
arg(:preferred_username, non_null(:string))
|
||||
resolve(&Resolvers.Group.find_group/3)
|
||||
resolve(&Group.find_group/3)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,7 +102,17 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
description: "The actor's username which will be the admin (otherwise user's default one)"
|
||||
)
|
||||
|
||||
resolve(&Resolvers.Group.create_group/3)
|
||||
arg(:avatar, :picture_input,
|
||||
description:
|
||||
"The avatar for the group, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
arg(:banner, :picture_input,
|
||||
description:
|
||||
"The banner for the group, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
resolve(&Group.create_group/3)
|
||||
end
|
||||
|
||||
@desc "Delete a group"
|
||||
@@ -109,7 +120,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
||||
arg(:group_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
|
||||
resolve(&Resolvers.Group.delete_group/3)
|
||||
resolve(&Group.delete_group/3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
use Absinthe.Schema.Notation
|
||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||
alias Mobilizon.Events
|
||||
alias MobilizonWeb.Resolvers
|
||||
alias MobilizonWeb.Resolvers.Person
|
||||
import MobilizonWeb.Schema.Utils
|
||||
|
||||
import_types(MobilizonWeb.Schema.Events.FeedTokenType)
|
||||
@@ -34,8 +34,9 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
)
|
||||
|
||||
field(:suspended, :boolean, description: "If the actor is suspended")
|
||||
field(:avatar_url, :string, description: "The actor's avatar url")
|
||||
field(:banner_url, :string, description: "The actor's banner url")
|
||||
|
||||
field(:avatar, :picture, description: "The actor's avatar picture")
|
||||
field(:banner, :picture, description: "The actor's banner picture")
|
||||
|
||||
# These one should have a privacy setting
|
||||
field(:following, list_of(:follower), description: "List of followings")
|
||||
@@ -56,25 +57,25 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
|
||||
@desc "The list of events this person goes to"
|
||||
field :going_to_events, list_of(:event) do
|
||||
resolve(&Resolvers.Person.person_going_to_events/3)
|
||||
resolve(&Person.person_going_to_events/3)
|
||||
end
|
||||
end
|
||||
|
||||
object :person_queries do
|
||||
@desc "Get the current actor for the logged-in user"
|
||||
field :logged_person, :person do
|
||||
resolve(&Resolvers.Person.get_current_person/3)
|
||||
resolve(&Person.get_current_person/3)
|
||||
end
|
||||
|
||||
@desc "Get a person by it's preferred username"
|
||||
field :person, :person do
|
||||
arg(:preferred_username, non_null(:string))
|
||||
resolve(&Resolvers.Person.find_person/3)
|
||||
resolve(&Person.find_person/3)
|
||||
end
|
||||
|
||||
@desc "Get the persons for an user"
|
||||
field :identities, list_of(:person) do
|
||||
resolve(&Resolvers.Person.identities/3)
|
||||
resolve(&Person.identities/3)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,7 +88,17 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
|
||||
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
|
||||
|
||||
resolve(handle_errors(&Resolvers.Person.create_person/3))
|
||||
arg(:avatar, :picture_input,
|
||||
description:
|
||||
"The avatar for the profile, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
arg(:banner, :picture_input,
|
||||
description:
|
||||
"The banner for the profile, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
resolve(handle_errors(&Person.create_person/3))
|
||||
end
|
||||
|
||||
@desc "Register a first profile on registration"
|
||||
@@ -99,7 +110,17 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
|
||||
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
|
||||
arg(:email, non_null(:string), description: "The email from the user previously created")
|
||||
|
||||
resolve(handle_errors(&Resolvers.Person.register_person/3))
|
||||
arg(:avatar, :picture_input,
|
||||
description:
|
||||
"The avatar for the profile, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
arg(:banner, :picture_input,
|
||||
description:
|
||||
"The banner for the profile, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
resolve(handle_errors(&Person.register_person/3))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
import_types(MobilizonWeb.Schema.AddressType)
|
||||
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
||||
import_types(MobilizonWeb.Schema.TagType)
|
||||
alias MobilizonWeb.Resolvers
|
||||
alias MobilizonWeb.Resolvers.{Picture, Event, Tag}
|
||||
|
||||
@desc "An event"
|
||||
object :event do
|
||||
@@ -23,10 +23,12 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
field(:ends_on, :datetime, description: "Datetime for when the event ends")
|
||||
field(:status, :event_status, description: "Status of the event")
|
||||
field(:visibility, :event_visibility, description: "The event's visibility")
|
||||
# TODO replace me with picture object
|
||||
field(:thumbnail, :string, description: "A thumbnail picture for the event")
|
||||
# TODO replace me with banner
|
||||
field(:large_image, :string, description: "A large picture for the event")
|
||||
|
||||
field(:picture, :picture,
|
||||
description: "The event's picture",
|
||||
resolve: &Picture.picture/3
|
||||
)
|
||||
|
||||
field(:publish_at, :datetime, description: "When the event was published")
|
||||
|
||||
field(:physical_address, :address,
|
||||
@@ -45,19 +47,19 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
field(:attributed_to, :actor, description: "Who the event is attributed to (often a group)")
|
||||
|
||||
field(:tags, list_of(:tag),
|
||||
resolve: &MobilizonWeb.Resolvers.Tag.list_tags_for_event/3,
|
||||
resolve: &Tag.list_tags_for_event/3,
|
||||
description: "The event's tags"
|
||||
)
|
||||
|
||||
field(:category, :string, description: "The event's category")
|
||||
|
||||
field(:participants, list_of(:participant),
|
||||
resolve: &MobilizonWeb.Resolvers.Event.list_participants_for_event/3,
|
||||
resolve: &Event.list_participants_for_event/3,
|
||||
description: "The event's participants"
|
||||
)
|
||||
|
||||
field(:related_events, list_of(:event),
|
||||
resolve: &MobilizonWeb.Resolvers.Event.list_related_events/3,
|
||||
resolve: &Event.list_related_events/3,
|
||||
description: "Events related to this one"
|
||||
)
|
||||
|
||||
@@ -93,13 +95,13 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
field :events, list_of(:event) do
|
||||
arg(:page, :integer, default_value: 1)
|
||||
arg(:limit, :integer, default_value: 10)
|
||||
resolve(&Resolvers.Event.list_events/3)
|
||||
resolve(&Event.list_events/3)
|
||||
end
|
||||
|
||||
@desc "Get an event by uuid"
|
||||
field :event, :event do
|
||||
arg(:uuid, non_null(:uuid))
|
||||
resolve(&Resolvers.Event.find_event/3)
|
||||
resolve(&Event.find_event/3)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -113,15 +115,20 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
arg(:state, :integer)
|
||||
arg(:status, :integer)
|
||||
arg(:public, :boolean)
|
||||
arg(:thumbnail, :string)
|
||||
arg(:large_image, :string)
|
||||
arg(:visibility, :event_visibility, default_value: :private)
|
||||
|
||||
arg(:picture, :picture_input,
|
||||
description:
|
||||
"The picture for the event, either as an object or directly the ID of an existing Picture"
|
||||
)
|
||||
|
||||
arg(:publish_at, :datetime)
|
||||
arg(:online_address, :string)
|
||||
arg(:phone_address, :string)
|
||||
arg(:organizer_actor_id, non_null(:id))
|
||||
arg(:category, non_null(:string))
|
||||
|
||||
resolve(&Resolvers.Event.create_event/3)
|
||||
resolve(&Event.create_event/3)
|
||||
end
|
||||
|
||||
@desc "Delete an event"
|
||||
@@ -129,7 +136,7 @@ defmodule MobilizonWeb.Schema.EventType do
|
||||
arg(:event_id, non_null(:integer))
|
||||
arg(:actor_id, non_null(:integer))
|
||||
|
||||
resolve(&Resolvers.Event.delete_event/3)
|
||||
resolve(&Event.delete_event/3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
48
lib/mobilizon_web/schema/picture.ex
Normal file
48
lib/mobilizon_web/schema/picture.ex
Normal file
@@ -0,0 +1,48 @@
|
||||
defmodule MobilizonWeb.Schema.PictureType do
|
||||
@moduledoc """
|
||||
Schema representation for Pictures
|
||||
"""
|
||||
use Absinthe.Schema.Notation
|
||||
alias MobilizonWeb.Resolvers.Picture
|
||||
|
||||
@desc "A picture"
|
||||
object :picture do
|
||||
field(:id, :id, description: "The picture's ID")
|
||||
field(:alt, :string, description: "The picture's alternative text")
|
||||
field(:name, :string, description: "The picture's name")
|
||||
field(:url, :string, description: "The picture's full URL")
|
||||
end
|
||||
|
||||
@desc "An attached picture or a link to a picture"
|
||||
input_object :picture_input do
|
||||
# Either a full picture object
|
||||
field(:picture, :picture_input_object)
|
||||
# Or directly the ID of an existing picture
|
||||
field(:picture_id, :string)
|
||||
end
|
||||
|
||||
@desc "An attached picture"
|
||||
input_object :picture_input_object do
|
||||
field(:name, non_null(:string))
|
||||
field(:alt, :string)
|
||||
field(:file, non_null(:upload))
|
||||
end
|
||||
|
||||
object :picture_queries do
|
||||
@desc "Get a picture"
|
||||
field :picture, :picture do
|
||||
arg(:id, non_null(:string))
|
||||
resolve(&Picture.picture/3)
|
||||
end
|
||||
end
|
||||
|
||||
object :picture_mutations do
|
||||
@desc "Upload a picture"
|
||||
field :upload_picture, :picture do
|
||||
arg(:name, non_null(:string))
|
||||
arg(:alt, :string)
|
||||
arg(:file, non_null(:upload))
|
||||
resolve(&Picture.upload_picture/3)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user