Merge branch 'split-web-graphql' into 'master'
Split of GraphQL and Web contexts See merge request framasoft/mobilizon!383
This commit is contained in:
commit
a781c2d3e2
@ -36,18 +36,18 @@ config :mime, :types, %{
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
secret_key_base: "1yOazsoE0Wqu4kXk3uC5gu3jDbShOimTCzyFL3OjCdBmOXMyHX87Qmf3+Tu9s0iM",
|
secret_key_base: "1yOazsoE0Wqu4kXk3uC5gu3jDbShOimTCzyFL3OjCdBmOXMyHX87Qmf3+Tu9s0iM",
|
||||||
render_errors: [view: MobilizonWeb.ErrorView, accepts: ~w(html json)],
|
render_errors: [view: Mobilizon.Web.ErrorView, accepts: ~w(html json)],
|
||||||
pubsub: [name: Mobilizon.PubSub, adapter: Phoenix.PubSub.PG2]
|
pubsub: [name: Mobilizon.PubSub, adapter: Phoenix.PubSub.PG2]
|
||||||
|
|
||||||
# Upload configuration
|
# Upload configuration
|
||||||
config :mobilizon, MobilizonWeb.Upload,
|
config :mobilizon, Mobilizon.Web.Upload,
|
||||||
uploader: MobilizonWeb.Upload.Uploader.Local,
|
uploader: Mobilizon.Web.Upload.Uploader.Local,
|
||||||
filters: [
|
filters: [
|
||||||
MobilizonWeb.Upload.Filter.Dedupe,
|
Mobilizon.Web.Upload.Filter.Dedupe,
|
||||||
MobilizonWeb.Upload.Filter.Optimize
|
Mobilizon.Web.Upload.Filter.Optimize
|
||||||
],
|
],
|
||||||
link_name: true,
|
link_name: true,
|
||||||
proxy_remote: false,
|
proxy_remote: false,
|
||||||
@ -60,7 +60,7 @@ config :mobilizon, MobilizonWeb.Upload,
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Upload.Uploader.Local, uploads: "uploads"
|
config :mobilizon, Mobilizon.Web.Upload.Uploader.Local, uploads: "uploads"
|
||||||
|
|
||||||
config :mobilizon, :media_proxy,
|
config :mobilizon, :media_proxy,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@ -78,7 +78,7 @@ config :logger, :console,
|
|||||||
format: "$time $metadata[$level] $message\n",
|
format: "$time $metadata[$level] $message\n",
|
||||||
metadata: [:request_id]
|
metadata: [:request_id]
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Auth.Guardian,
|
config :mobilizon, Mobilizon.Web.Auth.Guardian,
|
||||||
issuer: "mobilizon",
|
issuer: "mobilizon",
|
||||||
secret_key: "ty0WM7YBE3ojvxoUQxo8AERrNpfbXnIJ82ovkPdqbUFw31T5LcK8wGjaOiReVQjo"
|
secret_key: "ty0WM7YBE3ojvxoUQxo8AERrNpfbXnIJ82ovkPdqbUFw31T5LcK8wGjaOiReVQjo"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import Config
|
|||||||
# The watchers configuration can be used to run external
|
# The watchers configuration can be used to run external
|
||||||
# watchers to your application. For example, we use it
|
# watchers to your application. For example, we use it
|
||||||
# with brunch.io to recompile .js and .css sources.
|
# with brunch.io to recompile .js and .css sources.
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
http: [
|
http: [
|
||||||
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 4000
|
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 4000
|
||||||
],
|
],
|
||||||
@ -39,7 +39,7 @@ config :mobilizon, MobilizonWeb.Endpoint,
|
|||||||
# different ports.
|
# different ports.
|
||||||
|
|
||||||
# Watch static and templates for browser reloading.
|
# Watch static and templates for browser reloading.
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
live_reload: [
|
live_reload: [
|
||||||
patterns: [
|
patterns: [
|
||||||
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
|
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
|
||||||
@ -61,7 +61,7 @@ config :phoenix, :stacktrace_depth, 20
|
|||||||
# Initialize plugs at runtime for faster development compilation
|
# Initialize plugs at runtime for faster development compilation
|
||||||
config :phoenix, :plug_init_mode, :runtime
|
config :phoenix, :plug_init_mode, :runtime
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Email.Mailer, adapter: Bamboo.LocalAdapter
|
config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Bamboo.LocalAdapter
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :mobilizon, Mobilizon.Storage.Repo,
|
config :mobilizon, Mobilizon.Storage.Repo,
|
||||||
|
@ -2,7 +2,7 @@ import Config
|
|||||||
|
|
||||||
import_config "dev.exs"
|
import_config "dev.exs"
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
http: [
|
http: [
|
||||||
port: 4000
|
port: 4000
|
||||||
],
|
],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
http: [
|
http: [
|
||||||
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 4000,
|
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 4000,
|
||||||
transport_options: [socket_opts: [:inet6]]
|
transport_options: [socket_opts: [:inet6]]
|
||||||
@ -24,7 +24,7 @@ config :mobilizon, Mobilizon.Storage.Repo,
|
|||||||
port: System.get_env("MOBILIZON_DATABASE_PORT") || "5432",
|
port: System.get_env("MOBILIZON_DATABASE_PORT") || "5432",
|
||||||
pool_size: 15
|
pool_size: 15
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Email.Mailer,
|
config :mobilizon, Mobilizon.Web.Email.Mailer,
|
||||||
adapter: Bamboo.SMTPAdapter,
|
adapter: Bamboo.SMTPAdapter,
|
||||||
server: "localhost",
|
server: "localhost",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
@ -53,7 +53,7 @@ config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geos
|
|||||||
# To get SSL working, you will need to add the `https` key
|
# To get SSL working, you will need to add the `https` key
|
||||||
# to the previous section and set your `:url` port to 443:
|
# to the previous section and set your `:url` port to 443:
|
||||||
#
|
#
|
||||||
# config :mobilizon, MobilizonWeb.Endpoint,
|
# config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
# ...
|
# ...
|
||||||
# url: [host: "example.com", port: 443],
|
# url: [host: "example.com", port: 443],
|
||||||
# https: [:inet6,
|
# https: [:inet6,
|
||||||
@ -68,7 +68,7 @@ config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geos
|
|||||||
# We also recommend setting `force_ssl`, ensuring no data is
|
# We also recommend setting `force_ssl`, ensuring no data is
|
||||||
# ever sent via http, always redirecting to https:
|
# ever sent via http, always redirecting to https:
|
||||||
#
|
#
|
||||||
# config :mobilizon, MobilizonWeb.Endpoint,
|
# config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
# force_ssl: [hsts: true]
|
# force_ssl: [hsts: true]
|
||||||
#
|
#
|
||||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||||
@ -83,5 +83,5 @@ config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geos
|
|||||||
# Alternatively, you can configure exactly which server to
|
# Alternatively, you can configure exactly which server to
|
||||||
# start per endpoint:
|
# start per endpoint:
|
||||||
#
|
#
|
||||||
# config :mobilizon, MobilizonWeb.Endpoint, server: true
|
# config :mobilizon, Mobilizon.Web.Endpoint, server: true
|
||||||
#
|
#
|
||||||
|
@ -6,7 +6,7 @@ config :mobilizon, :instance,
|
|||||||
|
|
||||||
# We don't run a server during test. If one is required,
|
# We don't run a server during test. If one is required,
|
||||||
# you can enable the server option below.
|
# you can enable the server option below.
|
||||||
config :mobilizon, MobilizonWeb.Endpoint,
|
config :mobilizon, Mobilizon.Web.Endpoint,
|
||||||
http: [
|
http: [
|
||||||
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 80
|
port: System.get_env("MOBILIZON_INSTANCE_PORT") || 80
|
||||||
],
|
],
|
||||||
@ -30,11 +30,11 @@ config :mobilizon, Mobilizon.Storage.Repo,
|
|||||||
hostname: System.get_env("MOBILIZON_DATABASE_HOST") || "localhost",
|
hostname: System.get_env("MOBILIZON_DATABASE_HOST") || "localhost",
|
||||||
pool: Ecto.Adapters.SQL.Sandbox
|
pool: Ecto.Adapters.SQL.Sandbox
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Email.Mailer, adapter: Bamboo.TestAdapter
|
config :mobilizon, Mobilizon.Web.Email.Mailer, adapter: Bamboo.TestAdapter
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Upload, filters: [], link_name: false
|
config :mobilizon, Mobilizon.Web.Upload, filters: [], link_name: false
|
||||||
|
|
||||||
config :mobilizon, MobilizonWeb.Upload.Uploader.Local, uploads: "test/uploads"
|
config :mobilizon, Mobilizon.Web.Upload.Uploader.Local, uploads: "test/uploads"
|
||||||
|
|
||||||
config :exvcr,
|
config :exvcr,
|
||||||
vcr_cassette_library_dir: "test/fixtures/vcr_cassettes"
|
vcr_cassette_library_dir: "test/fixtures/vcr_cassettes"
|
||||||
|
@ -30,8 +30,9 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
alias Mobilizon.Federation.HTTPSignatures.Signature
|
alias Mobilizon.Federation.HTTPSignatures.Signature
|
||||||
alias Mobilizon.Federation.WebFinger
|
alias Mobilizon.Federation.WebFinger
|
||||||
|
|
||||||
alias MobilizonWeb.API.Utils, as: APIUtils
|
alias Mobilizon.GraphQL.API.Utils, as: APIUtils
|
||||||
alias MobilizonWeb.Email.{Admin, Mailer}
|
|
||||||
|
alias Mobilizon.Web.Email.{Admin, Mailer}
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -317,7 +318,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
Convertible.model_to_as(%{follow | actor: follower, target_actor: followed}),
|
Convertible.model_to_as(%{follow | actor: follower, target_actor: followed}),
|
||||||
{:ok, follow_activity} <- create_activity(follow_as_data, local),
|
{:ok, follow_activity} <- create_activity(follow_as_data, local),
|
||||||
activity_unfollow_id <-
|
activity_unfollow_id <-
|
||||||
activity_id || "#{MobilizonWeb.Endpoint.url()}/unfollow/#{follow_id}/activity",
|
activity_id || "#{Mobilizon.Web.Endpoint.url()}/unfollow/#{follow_id}/activity",
|
||||||
unfollow_data <-
|
unfollow_data <-
|
||||||
make_unfollow_data(follower, followed, follow_activity, activity_unfollow_id),
|
make_unfollow_data(follower, followed, follow_activity, activity_unfollow_id),
|
||||||
{:ok, activity} <- create_activity(unfollow_data, local),
|
{:ok, activity} <- create_activity(unfollow_data, local),
|
||||||
@ -482,7 +483,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
# If it's an exclusion it should be something else
|
# If it's an exclusion it should be something else
|
||||||
"actor" => actor_url,
|
"actor" => actor_url,
|
||||||
"object" => event_url,
|
"object" => event_url,
|
||||||
"id" => "#{MobilizonWeb.Endpoint.url()}/leave/event/#{participant.id}"
|
"id" => "#{Mobilizon.Web.Endpoint.url()}/leave/event/#{participant.id}"
|
||||||
},
|
},
|
||||||
audience <-
|
audience <-
|
||||||
Audience.calculate_to_and_cc_from_mentions(participant),
|
Audience.calculate_to_and_cc_from_mentions(participant),
|
||||||
@ -777,7 +778,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
make_accept_join_data(
|
make_accept_join_data(
|
||||||
follower_as_data,
|
follower_as_data,
|
||||||
Map.merge(additional, %{
|
Map.merge(additional, %{
|
||||||
"id" => "#{MobilizonWeb.Endpoint.url()}/accept/follow/#{follower.id}",
|
"id" => "#{Mobilizon.Web.Endpoint.url()}/accept/follow/#{follower.id}",
|
||||||
"to" => [follower.actor.url],
|
"to" => [follower.actor.url],
|
||||||
"cc" => [],
|
"cc" => [],
|
||||||
"actor" => follower.target_actor.url
|
"actor" => follower.target_actor.url
|
||||||
@ -796,7 +797,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
defp accept_join(%Participant{} = participant, additional) do
|
defp accept_join(%Participant{} = participant, additional) do
|
||||||
with {:ok, %Participant{} = participant} <-
|
with {:ok, %Participant{} = participant} <-
|
||||||
Events.update_participant(participant, %{role: :participant}),
|
Events.update_participant(participant, %{role: :participant}),
|
||||||
Absinthe.Subscription.publish(MobilizonWeb.Endpoint, participant.actor,
|
Absinthe.Subscription.publish(Mobilizon.Web.Endpoint, participant.actor,
|
||||||
event_person_participation_changed: participant.actor.id
|
event_person_participation_changed: participant.actor.id
|
||||||
),
|
),
|
||||||
participant_as_data <- Convertible.model_to_as(participant),
|
participant_as_data <- Convertible.model_to_as(participant),
|
||||||
@ -806,7 +807,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
make_accept_join_data(
|
make_accept_join_data(
|
||||||
participant_as_data,
|
participant_as_data,
|
||||||
Map.merge(Map.merge(audience, additional), %{
|
Map.merge(Map.merge(audience, additional), %{
|
||||||
"id" => "#{MobilizonWeb.Endpoint.url()}/accept/join/#{participant.id}"
|
"id" => "#{Mobilizon.Web.Endpoint.url()}/accept/join/#{participant.id}"
|
||||||
})
|
})
|
||||||
) do
|
) do
|
||||||
{:ok, participant, update_data}
|
{:ok, participant, update_data}
|
||||||
@ -822,7 +823,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
defp reject_join(%Participant{} = participant, additional) do
|
defp reject_join(%Participant{} = participant, additional) do
|
||||||
with {:ok, %Participant{} = participant} <-
|
with {:ok, %Participant{} = participant} <-
|
||||||
Events.update_participant(participant, %{approved: false, role: :rejected}),
|
Events.update_participant(participant, %{approved: false, role: :rejected}),
|
||||||
Absinthe.Subscription.publish(MobilizonWeb.Endpoint, participant.actor,
|
Absinthe.Subscription.publish(Mobilizon.Web.Endpoint, participant.actor,
|
||||||
event_person_participation_changed: participant.actor.id
|
event_person_participation_changed: participant.actor.id
|
||||||
),
|
),
|
||||||
participant_as_data <- Convertible.model_to_as(participant),
|
participant_as_data <- Convertible.model_to_as(participant),
|
||||||
@ -838,7 +839,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
reject_data
|
reject_data
|
||||||
|> Map.merge(audience)
|
|> Map.merge(audience)
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
"id" => "#{MobilizonWeb.Endpoint.url()}/reject/join/#{participant.id}"
|
"id" => "#{Mobilizon.Web.Endpoint.url()}/reject/join/#{participant.id}"
|
||||||
}) do
|
}) do
|
||||||
{:ok, participant, update_data}
|
{:ok, participant, update_data}
|
||||||
else
|
else
|
||||||
@ -865,7 +866,7 @@ defmodule Mobilizon.Federation.ActivityPub do
|
|||||||
reject_data
|
reject_data
|
||||||
|> Map.merge(audience)
|
|> Map.merge(audience)
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
"id" => "#{MobilizonWeb.Endpoint.url()}/reject/follow/#{follower.id}"
|
"id" => "#{Mobilizon.Web.Endpoint.url()}/reject/follow/#{follower.id}"
|
||||||
}) do
|
}) do
|
||||||
{:ok, follower, update_data}
|
{:ok, follower, update_data}
|
||||||
else
|
else
|
||||||
|
@ -15,7 +15,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
|
|||||||
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier}
|
||||||
alias Mobilizon.Federation.WebFinger
|
alias Mobilizon.Federation.WebFinger
|
||||||
|
|
||||||
alias MobilizonWeb.API.Follows
|
alias Mobilizon.GraphQL.API.Follows
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
|
|||||||
@spec get_actor() :: Actor.t() | {:error, Ecto.Changeset.t()}
|
@spec get_actor() :: Actor.t() | {:error, Ecto.Changeset.t()}
|
||||||
def get_actor do
|
def get_actor do
|
||||||
with {:ok, %Actor{} = actor} <-
|
with {:ok, %Actor{} = actor} <-
|
||||||
Actors.get_or_create_instance_actor_by_url("#{MobilizonWeb.Endpoint.url()}/relay") do
|
Actors.get_or_create_instance_actor_by_url("#{Mobilizon.Web.Endpoint.url()}/relay") do
|
||||||
actor
|
actor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
|
|||||||
alias Mobilizon.Federation.ActivityPub.{Activity, Utils}
|
alias Mobilizon.Federation.ActivityPub.{Activity, Utils}
|
||||||
alias Mobilizon.Federation.ActivityStream.{Converter, Convertible}
|
alias Mobilizon.Federation.ActivityStream.{Converter, Convertible}
|
||||||
|
|
||||||
alias MobilizonWeb.Email.Participation
|
alias Mobilizon.Web.Email.Participation
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
|
|||||||
Save picture data from %Plug.Upload{} and return AS Link data.
|
Save picture data from %Plug.Upload{} and return AS Link data.
|
||||||
"""
|
"""
|
||||||
def make_picture_data(%Plug.Upload{} = picture, opts) do
|
def make_picture_data(%Plug.Upload{} = picture, opts) do
|
||||||
case MobilizonWeb.Upload.store(picture, opts) do
|
case Mobilizon.Web.Upload.store(picture, opts) do
|
||||||
{:ok, picture} ->
|
{:ok, picture} ->
|
||||||
picture
|
picture
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
|
|||||||
"""
|
"""
|
||||||
def make_picture_data(picture) when is_map(picture) do
|
def make_picture_data(picture) when is_map(picture) do
|
||||||
with {:ok, %{"url" => [%{"href" => url, "mediaType" => content_type}], "size" => size}} <-
|
with {:ok, %{"url" => [%{"href" => url, "mediaType" => content_type}], "size" => size}} <-
|
||||||
MobilizonWeb.Upload.store(picture.file),
|
Mobilizon.Web.Upload.store(picture.file),
|
||||||
{:picture_exists, nil} <- {:picture_exists, Mobilizon.Media.get_picture_by_url(url)},
|
{:picture_exists, nil} <- {:picture_exists, Mobilizon.Media.get_picture_by_url(url)},
|
||||||
{:ok, %Picture{file: _file} = picture} <-
|
{:ok, %Picture{file: _file} = picture} <-
|
||||||
Mobilizon.Media.create_picture(%{
|
Mobilizon.Media.create_picture(%{
|
||||||
|
@ -29,14 +29,14 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Actor do
|
|||||||
data["icon"]["url"] &&
|
data["icon"]["url"] &&
|
||||||
%{
|
%{
|
||||||
"name" => data["icon"]["name"] || "avatar",
|
"name" => data["icon"]["name"] || "avatar",
|
||||||
"url" => MobilizonWeb.MediaProxy.url(data["icon"]["url"])
|
"url" => Mobilizon.Web.MediaProxy.url(data["icon"]["url"])
|
||||||
}
|
}
|
||||||
|
|
||||||
banner =
|
banner =
|
||||||
data["image"]["url"] &&
|
data["image"]["url"] &&
|
||||||
%{
|
%{
|
||||||
"name" => data["image"]["name"] || "banner",
|
"name" => data["image"]["name"] || "banner",
|
||||||
"url" => MobilizonWeb.MediaProxy.url(data["image"]["url"])
|
"url" => Mobilizon.Web.MediaProxy.url(data["image"]["url"])
|
||||||
}
|
}
|
||||||
|
|
||||||
actor_data = %{
|
actor_data = %{
|
||||||
|
@ -34,7 +34,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Picture do
|
|||||||
when is_bitstring(picture_url) do
|
when is_bitstring(picture_url) do
|
||||||
with {:ok, %HTTPoison.Response{body: body}} <- HTTPoison.get(picture_url),
|
with {:ok, %HTTPoison.Response{body: body}} <- HTTPoison.get(picture_url),
|
||||||
{:ok, %{name: name, url: url, content_type: content_type, size: size}} <-
|
{:ok, %{name: name, url: url, content_type: content_type, size: size}} <-
|
||||||
MobilizonWeb.Upload.store(%{body: body, name: name}),
|
Mobilizon.Web.Upload.store(%{body: body, name: name}),
|
||||||
{:picture_exists, nil} <- {:picture_exists, Mobilizon.Media.get_picture_by_url(url)} do
|
{:picture_exists, nil} <- {:picture_exists, Mobilizon.Media.get_picture_by_url(url)} do
|
||||||
Mobilizon.Media.create_picture(%{
|
Mobilizon.Media.create_picture(%{
|
||||||
"file" => %{
|
"file" => %{
|
||||||
|
@ -40,7 +40,7 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
|
|||||||
def build_tags(tags) do
|
def build_tags(tags) do
|
||||||
Enum.map(tags, fn %Tag{} = tag ->
|
Enum.map(tags, fn %Tag{} = tag ->
|
||||||
%{
|
%{
|
||||||
"href" => MobilizonWeb.Endpoint.url() <> "/tags/#{tag.slug}",
|
"href" => Mobilizon.Web.Endpoint.url() <> "/tags/#{tag.slug}",
|
||||||
"name" => "##{tag.title}",
|
"name" => "##{tag.title}",
|
||||||
"type" => "Hashtag"
|
"type" => "Hashtag"
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ defmodule Mobilizon.Federation.WebFinger do
|
|||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
def host_meta do
|
def host_meta do
|
||||||
base_url = MobilizonWeb.Endpoint.url()
|
base_url = Mobilizon.Web.Endpoint.url()
|
||||||
|
|
||||||
{
|
{
|
||||||
:XRD,
|
:XRD,
|
||||||
@ -35,7 +35,7 @@ defmodule Mobilizon.Federation.WebFinger do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def webfinger(resource, "JSON") do
|
def webfinger(resource, "JSON") do
|
||||||
host = MobilizonWeb.Endpoint.host()
|
host = Mobilizon.Web.Endpoint.host()
|
||||||
regex = ~r/(acct:)?(?<name>\w+)@#{host}/
|
regex = ~r/(acct:)?(?<name>\w+)@#{host}/
|
||||||
|
|
||||||
with %{"name" => name} <- Regex.named_captures(regex, resource),
|
with %{"name" => name} <- Regex.named_captures(regex, resource),
|
||||||
@ -59,7 +59,7 @@ defmodule Mobilizon.Federation.WebFinger do
|
|||||||
@spec represent_actor(Actor.t(), String.t()) :: struct()
|
@spec represent_actor(Actor.t(), String.t()) :: struct()
|
||||||
def represent_actor(actor, "JSON") do
|
def represent_actor(actor, "JSON") do
|
||||||
%{
|
%{
|
||||||
"subject" => "acct:#{actor.preferred_username}@#{MobilizonWeb.Endpoint.host()}",
|
"subject" => "acct:#{actor.preferred_username}@#{Mobilizon.Web.Endpoint.host()}",
|
||||||
"aliases" => [actor.url],
|
"aliases" => [actor.url],
|
||||||
"links" => [
|
"links" => [
|
||||||
%{"rel" => "self", "type" => "application/activity+json", "href" => actor.url},
|
%{"rel" => "self", "type" => "application/activity+json", "href" => actor.url},
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
defmodule MobilizonWeb.API.Comments do
|
defmodule Mobilizon.GraphQL.API.Comments do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
API for Comments.
|
API for Comments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Events.Comment
|
alias Mobilizon.Events.Comment
|
||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub
|
alias Mobilizon.Federation.ActivityPub
|
||||||
@ -12,8 +13,7 @@ defmodule MobilizonWeb.API.Comments do
|
|||||||
|
|
||||||
Creates a comment from an actor
|
Creates a comment from an actor
|
||||||
"""
|
"""
|
||||||
@spec create_comment(map()) ::
|
@spec create_comment(map) :: {:ok, Activity.t(), Comment.t()} | any
|
||||||
{:ok, Activity.t(), Comment.t()} | any()
|
|
||||||
def create_comment(args) do
|
def create_comment(args) do
|
||||||
ActivityPub.create(:comment, args, true)
|
ActivityPub.create(:comment, args, true)
|
||||||
end
|
end
|
||||||
@ -23,8 +23,7 @@ defmodule MobilizonWeb.API.Comments do
|
|||||||
|
|
||||||
Deletes a comment from an actor
|
Deletes a comment from an actor
|
||||||
"""
|
"""
|
||||||
@spec delete_comment(Comment.t()) ::
|
@spec delete_comment(Comment.t()) :: {:ok, Activity.t(), Comment.t()} | any
|
||||||
{:ok, Activity.t(), Comment.t()} | any()
|
|
||||||
def delete_comment(%Comment{} = comment) do
|
def delete_comment(%Comment{} = comment) do
|
||||||
ActivityPub.delete(comment, true)
|
ActivityPub.delete(comment, true)
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Events do
|
defmodule Mobilizon.GraphQL.API.Events do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
API for Events.
|
API for Events.
|
||||||
"""
|
"""
|
||||||
@ -12,7 +12,7 @@ defmodule MobilizonWeb.API.Events do
|
|||||||
@doc """
|
@doc """
|
||||||
Create an event
|
Create an event
|
||||||
"""
|
"""
|
||||||
@spec create_event(map()) :: {:ok, Activity.t(), Event.t()} | any()
|
@spec create_event(map) :: {:ok, Activity.t(), Event.t()} | any
|
||||||
def create_event(args) do
|
def create_event(args) do
|
||||||
with organizer_actor <- Map.get(args, :organizer_actor),
|
with organizer_actor <- Map.get(args, :organizer_actor),
|
||||||
args <-
|
args <-
|
||||||
@ -27,7 +27,7 @@ defmodule MobilizonWeb.API.Events do
|
|||||||
@doc """
|
@doc """
|
||||||
Update an event
|
Update an event
|
||||||
"""
|
"""
|
||||||
@spec update_event(map(), Event.t()) :: {:ok, Activity.t(), Event.t()} | any()
|
@spec update_event(map, Event.t()) :: {:ok, Activity.t(), Event.t()} | any
|
||||||
def update_event(args, %Event{} = event) do
|
def update_event(args, %Event{} = event) do
|
||||||
with organizer_actor <- Map.get(args, :organizer_actor),
|
with organizer_actor <- Map.get(args, :organizer_actor),
|
||||||
args <-
|
args <-
|
||||||
@ -53,7 +53,9 @@ defmodule MobilizonWeb.API.Events do
|
|||||||
defp process_picture(%{picture: picture}, %Actor{id: actor_id}) do
|
defp process_picture(%{picture: picture}, %Actor{id: actor_id}) do
|
||||||
%{
|
%{
|
||||||
file:
|
file:
|
||||||
picture |> Map.get(:file) |> Utils.make_picture_data(description: Map.get(picture, :name)),
|
picture
|
||||||
|
|> Map.get(:file)
|
||||||
|
|> Utils.make_picture_data(description: Map.get(picture, :name)),
|
||||||
actor_id: actor_id
|
actor_id: actor_id
|
||||||
}
|
}
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Follows do
|
defmodule Mobilizon.GraphQL.API.Follows do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Common API for following, unfollowing, accepting and rejecting stuff.
|
Common API for following, unfollowing, accepting and rejecting stuff.
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Groups do
|
defmodule Mobilizon.GraphQL.API.Groups do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
API for Groups.
|
API for Groups.
|
||||||
"""
|
"""
|
||||||
@ -12,7 +12,7 @@ defmodule MobilizonWeb.API.Groups do
|
|||||||
@doc """
|
@doc """
|
||||||
Create a group
|
Create a group
|
||||||
"""
|
"""
|
||||||
@spec create_group(map()) :: {:ok, Activity.t(), Actor.t()} | any()
|
@spec create_group(map) :: {:ok, Activity.t(), Actor.t()} | any
|
||||||
def create_group(args) do
|
def create_group(args) do
|
||||||
with preferred_username <-
|
with preferred_username <-
|
||||||
args |> Map.get(:preferred_username) |> HtmlSanitizeEx.strip_tags() |> String.trim(),
|
args |> Map.get(:preferred_username) |> HtmlSanitizeEx.strip_tags() |> String.trim(),
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Participations do
|
defmodule Mobilizon.GraphQL.API.Participations do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Common API to join events and groups.
|
Common API to join events and groups.
|
||||||
"""
|
"""
|
||||||
@ -8,7 +8,7 @@ defmodule MobilizonWeb.API.Participations do
|
|||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub
|
alias Mobilizon.Federation.ActivityPub
|
||||||
|
|
||||||
alias MobilizonWeb.Email.Participation
|
alias Mobilizon.Web.Email.Participation
|
||||||
|
|
||||||
@spec join(Event.t(), Actor.t()) :: {:ok, Participant.t()}
|
@spec join(Event.t(), Actor.t()) :: {:ok, Participant.t()}
|
||||||
def join(%Event{id: event_id} = event, %Actor{id: actor_id} = actor) do
|
def join(%Event{id: event_id} = event, %Actor{id: actor_id} = actor) do
|
||||||
@ -27,11 +27,13 @@ defmodule MobilizonWeb.API.Participations do
|
|||||||
@doc """
|
@doc """
|
||||||
Update participation status
|
Update participation status
|
||||||
"""
|
"""
|
||||||
def update(%Participant{} = participation, %Actor{} = moderator, :participant),
|
def update(%Participant{} = participation, %Actor{} = moderator, :participant) do
|
||||||
do: accept(participation, moderator)
|
accept(participation, moderator)
|
||||||
|
end
|
||||||
|
|
||||||
def update(%Participant{} = participation, %Actor{} = moderator, :rejected),
|
def update(%Participant{} = participation, %Actor{} = moderator, :rejected) do
|
||||||
do: reject(participation, moderator)
|
reject(participation, moderator)
|
||||||
|
end
|
||||||
|
|
||||||
defp accept(
|
defp accept(
|
||||||
%Participant{} = participation,
|
%Participant{} = participation,
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Reports do
|
defmodule Mobilizon.GraphQL.API.Reports do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
API for Reports.
|
API for Reports.
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Search do
|
defmodule Mobilizon.GraphQL.API.Search do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
API for search.
|
API for search.
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.API.Utils do
|
defmodule Mobilizon.GraphQL.API.Utils do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Utils for API.
|
Utils for API.
|
||||||
"""
|
"""
|
||||||
@ -10,11 +10,7 @@ defmodule MobilizonWeb.API.Utils do
|
|||||||
Creates HTML content from text and mentions
|
Creates HTML content from text and mentions
|
||||||
"""
|
"""
|
||||||
@spec make_content_html(String.t(), list(), String.t()) :: String.t()
|
@spec make_content_html(String.t(), list(), String.t()) :: String.t()
|
||||||
def make_content_html(
|
def make_content_html(text, additional_tags, content_type) do
|
||||||
text,
|
|
||||||
additional_tags,
|
|
||||||
content_type
|
|
||||||
) do
|
|
||||||
with {text, mentions, tags} <- format_input(text, content_type, []) do
|
with {text, mentions, tags} <- format_input(text, content_type, []) do
|
||||||
{text, mentions, additional_tags ++ Enum.map(tags, fn {_, tag} -> tag end)}
|
{text, mentions, additional_tags ++ Enum.map(tags, fn {_, tag} -> tag end)}
|
||||||
end
|
end
|
||||||
@ -24,9 +20,7 @@ defmodule MobilizonWeb.API.Utils do
|
|||||||
text
|
text
|
||||||
|> Formatter.html_escape("text/plain")
|
|> Formatter.html_escape("text/plain")
|
||||||
|> Formatter.linkify(options)
|
|> Formatter.linkify(options)
|
||||||
|> (fn {text, mentions, tags} ->
|
|> (fn {text, mentions, tags} -> {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags} end).()
|
||||||
{String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
|
|
||||||
end).()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_input(text, "text/html", options) do
|
def format_input(text, "text/html", options) do
|
@ -1,6 +1,6 @@
|
|||||||
defmodule MobilizonWeb.Schema.Utils do
|
defmodule Mobilizon.GraphQL.Helpers.Error do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Helper functions for MobilizonWeb.Schema
|
Helper functions for Mobilizon.GraphQL
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def handle_errors(fun) do
|
def handle_errors(fun) do
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Address do
|
defmodule Mobilizon.GraphQL.Resolvers.Address do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the comment-related GraphQL calls
|
Handles the comment-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
@ -11,10 +11,12 @@ defmodule MobilizonWeb.Resolvers.Address do
|
|||||||
@doc """
|
@doc """
|
||||||
Search an address
|
Search an address
|
||||||
"""
|
"""
|
||||||
@spec search(map(), map(), map()) :: {:ok, list(Address.t())}
|
@spec search(map, map, map) :: {:ok, [Address.t()]}
|
||||||
def search(_parent, %{query: query, locale: locale, page: _page, limit: _limit}, %{
|
def search(
|
||||||
context: %{ip: ip}
|
_parent,
|
||||||
}) do
|
%{query: query, locale: locale, page: _page, limit: _limit},
|
||||||
|
%{context: %{ip: ip}}
|
||||||
|
) do
|
||||||
geolix = Geolix.lookup(ip)
|
geolix = Geolix.lookup(ip)
|
||||||
|
|
||||||
country_code =
|
country_code =
|
||||||
@ -31,7 +33,7 @@ defmodule MobilizonWeb.Resolvers.Address do
|
|||||||
@doc """
|
@doc """
|
||||||
Reverse geocode some coordinates
|
Reverse geocode some coordinates
|
||||||
"""
|
"""
|
||||||
@spec reverse_geocode(map(), map(), map()) :: {:ok, list(Address.t())}
|
@spec reverse_geocode(map, map, map) :: {:ok, [Address.t()]}
|
||||||
def reverse_geocode(
|
def reverse_geocode(
|
||||||
_parent,
|
_parent,
|
||||||
%{longitude: longitude, latitude: latitude, zoom: zoom, locale: locale},
|
%{longitude: longitude, latitude: latitude, zoom: zoom, locale: locale},
|
@ -1,13 +1,13 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Admin do
|
defmodule Mobilizon.GraphQL.Resolvers.Admin do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the report-related GraphQL calls.
|
Handles the report-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import Mobilizon.Users.Guards
|
import Mobilizon.Users.Guards
|
||||||
|
|
||||||
alias Mobilizon.Admin.ActionLog
|
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.Actors
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
alias Mobilizon.Admin.ActionLog
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.{Event, Comment}
|
alias Mobilizon.Events.{Event, Comment}
|
||||||
alias Mobilizon.Reports.{Note, Report}
|
alias Mobilizon.Reports.{Note, Report}
|
||||||
@ -68,36 +68,28 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform_action_log(Note, :create, %ActionLog{
|
defp transform_action_log(Note, :create, %ActionLog{changes: changes}) do
|
||||||
changes: changes
|
|
||||||
}) do
|
|
||||||
%{
|
%{
|
||||||
action: :note_creation,
|
action: :note_creation,
|
||||||
object: convert_changes_to_struct(Note, changes)
|
object: convert_changes_to_struct(Note, changes)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform_action_log(Note, :delete, %ActionLog{
|
defp transform_action_log(Note, :delete, %ActionLog{changes: changes}) do
|
||||||
changes: changes
|
|
||||||
}) do
|
|
||||||
%{
|
%{
|
||||||
action: :note_deletion,
|
action: :note_deletion,
|
||||||
object: convert_changes_to_struct(Note, changes)
|
object: convert_changes_to_struct(Note, changes)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform_action_log(Event, :delete, %ActionLog{
|
defp transform_action_log(Event, :delete, %ActionLog{changes: changes}) do
|
||||||
changes: changes
|
|
||||||
}) do
|
|
||||||
%{
|
%{
|
||||||
action: :event_deletion,
|
action: :event_deletion,
|
||||||
object: convert_changes_to_struct(Event, changes)
|
object: convert_changes_to_struct(Event, changes)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform_action_log(Comment, :delete, %ActionLog{
|
defp transform_action_log(Comment, :delete, %ActionLog{changes: changes}) do
|
||||||
changes: changes
|
|
||||||
}) do
|
|
||||||
%{
|
%{
|
||||||
action: :comment_deletion,
|
action: :comment_deletion,
|
||||||
object: convert_changes_to_struct(Comment, changes)
|
object: convert_changes_to_struct(Comment, changes)
|
||||||
@ -118,9 +110,7 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_dashboard(_parent, _args, %{
|
def get_dashboard(_parent, _args, %{context: %{current_user: %User{role: role}}})
|
||||||
context: %{current_user: %User{role: role}}
|
|
||||||
})
|
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
last_public_event_published =
|
last_public_event_published =
|
||||||
case Events.list_events(1, 1, :inserted_at, :desc) do
|
case Events.list_events(1, 1, :inserted_at, :desc) do
|
||||||
@ -142,9 +132,11 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
{:error, "You need to be logged-in and an administrator to access dashboard statistics"}
|
{:error, "You need to be logged-in and an administrator to access dashboard statistics"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_relay_followers(_parent, %{page: page, limit: limit}, %{
|
def list_relay_followers(
|
||||||
context: %{current_user: %User{role: role}}
|
_parent,
|
||||||
})
|
%{page: page, limit: limit},
|
||||||
|
%{context: %{current_user: %User{role: role}}}
|
||||||
|
)
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
with %Actor{} = relay_actor <- Relay.get_actor() do
|
with %Actor{} = relay_actor <- Relay.get_actor() do
|
||||||
%Page{} =
|
%Page{} =
|
||||||
@ -154,9 +146,11 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_relay_followings(_parent, %{page: page, limit: limit}, %{
|
def list_relay_followings(
|
||||||
context: %{current_user: %User{role: role}}
|
_parent,
|
||||||
})
|
%{page: page, limit: limit},
|
||||||
|
%{context: %{current_user: %User{role: role}}}
|
||||||
|
)
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
with %Actor{} = relay_actor <- Relay.get_actor() do
|
with %Actor{} = relay_actor <- Relay.get_actor() do
|
||||||
%Page{} =
|
%Page{} =
|
||||||
@ -188,9 +182,11 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_subscription(_parent, %{address: address}, %{
|
def accept_subscription(
|
||||||
context: %{current_user: %User{role: role}}
|
_parent,
|
||||||
})
|
%{address: address},
|
||||||
|
%{context: %{current_user: %User{role: role}}}
|
||||||
|
)
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
case Relay.accept(address) do
|
case Relay.accept(address) do
|
||||||
{:ok, _activity, follow} ->
|
{:ok, _activity, follow} ->
|
||||||
@ -201,9 +197,11 @@ defmodule MobilizonWeb.Resolvers.Admin do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject_subscription(_parent, %{address: address}, %{
|
def reject_subscription(
|
||||||
context: %{current_user: %User{role: role}}
|
_parent,
|
||||||
})
|
%{address: address},
|
||||||
|
%{context: %{current_user: %User{role: role}}}
|
||||||
|
)
|
||||||
when is_admin(role) do
|
when is_admin(role) do
|
||||||
case Relay.reject(address) do
|
case Relay.reject(address) do
|
||||||
{:ok, _activity, follow} ->
|
{:ok, _activity, follow} ->
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Comment do
|
defmodule Mobilizon.GraphQL.Resolvers.Comment do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the comment-related GraphQL calls.
|
Handles the comment-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -9,7 +9,7 @@ defmodule MobilizonWeb.Resolvers.Comment do
|
|||||||
alias Mobilizon.Events.Comment, as: CommentModel
|
alias Mobilizon.Events.Comment, as: CommentModel
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.API.Comments
|
alias Mobilizon.GraphQL.API.Comments
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -17,9 +17,11 @@ defmodule MobilizonWeb.Resolvers.Comment do
|
|||||||
{:ok, Events.get_thread_replies(thread_id)}
|
{:ok, Events.get_thread_replies(thread_id)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_comment(_parent, %{actor_id: actor_id} = args, %{
|
def create_comment(
|
||||||
context: %{current_user: %User{} = user}
|
_parent,
|
||||||
}) do
|
%{actor_id: actor_id} = args,
|
||||||
|
%{context: %{current_user: %User{} = user}}
|
||||||
|
) do
|
||||||
with {:is_owned, %Actor{} = _organizer_actor} <- User.owns_actor(user, actor_id),
|
with {:is_owned, %Actor{} = _organizer_actor} <- User.owns_actor(user, actor_id),
|
||||||
{:ok, _, %CommentModel{} = comment} <-
|
{:ok, _, %CommentModel{} = comment} <-
|
||||||
Comments.create_comment(args) do
|
Comments.create_comment(args) do
|
||||||
@ -34,9 +36,11 @@ defmodule MobilizonWeb.Resolvers.Comment do
|
|||||||
{:error, "You are not allowed to create a comment if not connected"}
|
{:error, "You are not allowed to create a comment if not connected"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_comment(_parent, %{actor_id: actor_id, comment_id: comment_id}, %{
|
def delete_comment(
|
||||||
context: %{current_user: %User{role: role} = user}
|
_parent,
|
||||||
}) do
|
%{actor_id: actor_id, comment_id: comment_id},
|
||||||
|
%{context: %{current_user: %User{role: role} = user}}
|
||||||
|
) do
|
||||||
with {actor_id, ""} <- Integer.parse(actor_id),
|
with {actor_id, ""} <- Integer.parse(actor_id),
|
||||||
{:is_owned, %Actor{} = _organizer_actor} <- User.owns_actor(user, actor_id),
|
{:is_owned, %Actor{} = _organizer_actor} <- User.owns_actor(user, actor_id),
|
||||||
%CommentModel{} = comment <- Events.get_comment_with_preload(comment_id) do
|
%CommentModel{} = comment <- Events.get_comment_with_preload(comment_id) do
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Config do
|
defmodule Mobilizon.GraphQL.Resolvers.Config do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the config-related GraphQL calls.
|
Handles the config-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -10,9 +10,7 @@ defmodule MobilizonWeb.Resolvers.Config do
|
|||||||
@doc """
|
@doc """
|
||||||
Gets config.
|
Gets config.
|
||||||
"""
|
"""
|
||||||
def get_config(_parent, _params, %{
|
def get_config(_parent, _params, %{context: %{ip: ip}}) do
|
||||||
context: %{ip: ip}
|
|
||||||
}) do
|
|
||||||
geolix = Geolix.lookup(ip)
|
geolix = Geolix.lookup(ip)
|
||||||
|
|
||||||
country_code =
|
country_code =
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Event do
|
defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the event-related GraphQL calls.
|
Handles the event-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -8,10 +8,10 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
alias Mobilizon.Events.{Event, Participant, EventParticipantStats}
|
alias Mobilizon.Events.{Event, Participant, EventParticipantStats}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub.Activity
|
alias Mobilizon.GraphQL.API
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Person
|
||||||
|
|
||||||
alias MobilizonWeb.API
|
alias Mobilizon.Federation.ActivityPub.Activity
|
||||||
alias MobilizonWeb.Resolvers.Person
|
|
||||||
|
|
||||||
# We limit the max number of events that can be retrieved
|
# We limit the max number of events that can be retrieved
|
||||||
@event_max_limit 100
|
@event_max_limit 100
|
||||||
@ -40,8 +40,9 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp find_private_event(_parent, %{uuid: uuid}, _resolution),
|
defp find_private_event(_parent, %{uuid: uuid}, _resolution) do
|
||||||
do: {:error, "Event with UUID #{uuid} not found"}
|
{:error, "Event with UUID #{uuid} not found"}
|
||||||
|
end
|
||||||
|
|
||||||
def find_event(parent, %{uuid: uuid} = args, resolution) do
|
def find_event(parent, %{uuid: uuid} = args, resolution) do
|
||||||
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
|
case {:has_event, Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid)} do
|
||||||
@ -216,11 +217,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
def update_participation(
|
def update_participation(
|
||||||
_parent,
|
_parent,
|
||||||
%{id: participation_id, moderator_actor_id: moderator_actor_id, role: new_role},
|
%{id: participation_id, moderator_actor_id: moderator_actor_id, role: new_role},
|
||||||
%{
|
%{context: %{current_user: user}}
|
||||||
context: %{
|
|
||||||
current_user: user
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) do
|
) do
|
||||||
# Check that moderator provided is rightly authenticated
|
# Check that moderator provided is rightly authenticated
|
||||||
with {:is_owned, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
with {:is_owned, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
||||||
@ -233,7 +230,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
{:actor_approve_permission,
|
{:actor_approve_permission,
|
||||||
Mobilizon.Events.moderator_for_event?(participation.event.id, moderator_actor_id)},
|
Mobilizon.Events.moderator_for_event?(participation.event.id, moderator_actor_id)},
|
||||||
{:ok, _activity, participation} <-
|
{:ok, _activity, participation} <-
|
||||||
MobilizonWeb.API.Participations.update(participation, moderator_actor, new_role) do
|
API.Participations.update(participation, moderator_actor, new_role) do
|
||||||
{:ok, participation}
|
{:ok, participation}
|
||||||
else
|
else
|
||||||
{:is_owned, nil} ->
|
{:is_owned, nil} ->
|
||||||
@ -270,7 +267,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
{:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
{:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
||||||
args_with_organizer <- Map.put(args, :organizer_actor, organizer_actor),
|
args_with_organizer <- Map.put(args, :organizer_actor, organizer_actor),
|
||||||
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
||||||
MobilizonWeb.API.Events.create_event(args_with_organizer) do
|
API.Events.create_event(args_with_organizer) do
|
||||||
{:ok, event}
|
{:ok, event}
|
||||||
else
|
else
|
||||||
{:is_owned, nil} ->
|
{:is_owned, nil} ->
|
||||||
@ -304,7 +301,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
User.owns_actor(user, organizer_actor_id),
|
User.owns_actor(user, organizer_actor_id),
|
||||||
args <- Map.put(args, :organizer_actor, organizer_actor),
|
args <- Map.put(args, :organizer_actor, organizer_actor),
|
||||||
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
||||||
MobilizonWeb.API.Events.update_event(args, event) do
|
API.Events.update_event(args, event) do
|
||||||
{:ok, event}
|
{:ok, event}
|
||||||
else
|
else
|
||||||
{:error, :event_not_found} ->
|
{:error, :event_not_found} ->
|
||||||
@ -362,7 +359,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp do_delete_event(event, federate \\ true) when is_boolean(federate) do
|
defp do_delete_event(event, federate \\ true) when is_boolean(federate) do
|
||||||
with {:ok, _activity, event} <- MobilizonWeb.API.Events.delete_event(event) do
|
with {:ok, _activity, event} <- API.Events.delete_event(event) do
|
||||||
{:ok, %{id: event.id}}
|
{:ok, %{id: event.id}}
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.FeedToken do
|
defmodule Mobilizon.GraphQL.Resolvers.FeedToken do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the feed tokens-related GraphQL calls.
|
Handles the feed tokens-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -13,10 +13,12 @@ defmodule MobilizonWeb.Resolvers.FeedToken do
|
|||||||
@doc """
|
@doc """
|
||||||
Create an feed token for an user and a defined actor
|
Create an feed token for an user and a defined actor
|
||||||
"""
|
"""
|
||||||
@spec create_feed_token(any(), map(), map()) :: {:ok, FeedToken.t()} | {:error, String.t()}
|
@spec create_feed_token(any, map, map) :: {:ok, FeedToken.t()} | {:error, String.t()}
|
||||||
def create_feed_token(_parent, %{actor_id: actor_id}, %{
|
def create_feed_token(
|
||||||
context: %{current_user: %User{id: id} = user}
|
_parent,
|
||||||
}) do
|
%{actor_id: actor_id},
|
||||||
|
%{context: %{current_user: %User{id: id} = user}}
|
||||||
|
) do
|
||||||
with {:is_owned, %Actor{}} <- User.owns_actor(user, actor_id),
|
with {:is_owned, %Actor{}} <- User.owns_actor(user, actor_id),
|
||||||
{:ok, feed_token} <- Events.create_feed_token(%{"user_id" => id, "actor_id" => actor_id}) do
|
{:ok, feed_token} <- Events.create_feed_token(%{"user_id" => id, "actor_id" => actor_id}) do
|
||||||
{:ok, feed_token}
|
{:ok, feed_token}
|
||||||
@ -29,16 +31,14 @@ defmodule MobilizonWeb.Resolvers.FeedToken do
|
|||||||
@doc """
|
@doc """
|
||||||
Create an feed token for an user
|
Create an feed token for an user
|
||||||
"""
|
"""
|
||||||
@spec create_feed_token(any(), map(), map()) :: {:ok, FeedToken.t()}
|
@spec create_feed_token(any, map, map) :: {:ok, FeedToken.t()}
|
||||||
def create_feed_token(_parent, %{}, %{
|
def create_feed_token(_parent, %{}, %{context: %{current_user: %User{id: id}}}) do
|
||||||
context: %{current_user: %User{id: id}}
|
|
||||||
}) do
|
|
||||||
with {:ok, feed_token} <- Events.create_feed_token(%{"user_id" => id}) do
|
with {:ok, feed_token} <- Events.create_feed_token(%{"user_id" => id}) do
|
||||||
{:ok, feed_token}
|
{:ok, feed_token}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec create_feed_token(any(), map(), map()) :: {:error, String.t()}
|
@spec create_feed_token(any, map, map) :: {:error, String.t()}
|
||||||
def create_feed_token(_parent, _args, %{}) do
|
def create_feed_token(_parent, _args, %{}) do
|
||||||
{:error, "You are not allowed to create a feed token if not connected"}
|
{:error, "You are not allowed to create a feed token if not connected"}
|
||||||
end
|
end
|
||||||
@ -46,10 +46,12 @@ defmodule MobilizonWeb.Resolvers.FeedToken do
|
|||||||
@doc """
|
@doc """
|
||||||
Delete a feed token
|
Delete a feed token
|
||||||
"""
|
"""
|
||||||
@spec delete_feed_token(any(), map(), map()) :: {:ok, map()} | {:error, String.t()}
|
@spec delete_feed_token(any, map, map) :: {:ok, map} | {:error, String.t()}
|
||||||
def delete_feed_token(_parent, %{token: token}, %{
|
def delete_feed_token(
|
||||||
context: %{current_user: %User{id: id} = _user}
|
_parent,
|
||||||
}) do
|
%{token: token},
|
||||||
|
%{context: %{current_user: %User{id: id} = _user}}
|
||||||
|
) do
|
||||||
with {:ok, token} <- Ecto.UUID.cast(token),
|
with {:ok, token} <- Ecto.UUID.cast(token),
|
||||||
{:no_token, %FeedToken{actor: actor, user: %User{} = user} = feed_token} <-
|
{:no_token, %FeedToken{actor: actor, user: %User{} = user} = feed_token} <-
|
||||||
{:no_token, Events.get_feed_token(token)},
|
{:no_token, Events.get_feed_token(token)},
|
||||||
@ -73,7 +75,7 @@ defmodule MobilizonWeb.Resolvers.FeedToken do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec delete_feed_token(any(), map(), map()) :: {:error, String.t()}
|
@spec delete_feed_token(any, map, map) :: {:error, String.t()}
|
||||||
def delete_feed_token(_parent, _args, %{}) do
|
def delete_feed_token(_parent, _args, %{}) do
|
||||||
{:error, "You are not allowed to delete a feed token if not connected"}
|
{:error, "You are not allowed to delete a feed token if not connected"}
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Group do
|
defmodule Mobilizon.GraphQL.Resolvers.Group do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the group-related GraphQL calls.
|
Handles the group-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -7,10 +7,10 @@ defmodule MobilizonWeb.Resolvers.Group do
|
|||||||
alias Mobilizon.Actors.{Actor, Member}
|
alias Mobilizon.Actors.{Actor, Member}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub
|
alias Mobilizon.GraphQL.API
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Person
|
||||||
|
|
||||||
alias MobilizonWeb.API
|
alias Mobilizon.Federation.ActivityPub
|
||||||
alias MobilizonWeb.Resolvers.Person
|
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -42,11 +42,7 @@ defmodule MobilizonWeb.Resolvers.Group do
|
|||||||
@doc """
|
@doc """
|
||||||
Create a new group. The creator is automatically added as admin
|
Create a new group. The creator is automatically added as admin
|
||||||
"""
|
"""
|
||||||
def create_group(
|
def create_group(_parent, args, %{context: %{current_user: user}}) do
|
||||||
_parent,
|
|
||||||
args,
|
|
||||||
%{context: %{current_user: user}}
|
|
||||||
) do
|
|
||||||
with creator_actor_id <- Map.get(args, :creator_actor_id),
|
with creator_actor_id <- Map.get(args, :creator_actor_id),
|
||||||
{:is_owned, %Actor{} = creator_actor} <- User.owns_actor(user, creator_actor_id),
|
{:is_owned, %Actor{} = creator_actor} <- User.owns_actor(user, creator_actor_id),
|
||||||
args <- Map.put(args, :creator_actor, creator_actor),
|
args <- Map.put(args, :creator_actor, creator_actor),
|
||||||
@ -180,7 +176,7 @@ defmodule MobilizonWeb.Resolvers.Group do
|
|||||||
# We check that the actor asking to leave the group is not it's only administrator
|
# We check that the actor asking to leave the group is not it's only administrator
|
||||||
# We start by fetching the list of administrator or creators and if there's only one of them
|
# We start by fetching the list of administrator or creators and if there's only one of them
|
||||||
# and that it's the actor requesting leaving the group we return true
|
# and that it's the actor requesting leaving the group we return true
|
||||||
@spec check_that_member_is_not_last_administrator(integer(), integer()) :: boolean()
|
@spec check_that_member_is_not_last_administrator(integer, integer) :: boolean
|
||||||
defp check_that_member_is_not_last_administrator(group_id, actor_id) do
|
defp check_that_member_is_not_last_administrator(group_id, actor_id) do
|
||||||
case Actors.list_administrator_members_for_group(group_id) do
|
case Actors.list_administrator_members_for_group(group_id) do
|
||||||
[%Member{actor: %Actor{id: member_actor_id}}] ->
|
[%Member{actor: %Actor{id: member_actor_id}}] ->
|
@ -1,7 +1,8 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Member do
|
defmodule Mobilizon.GraphQL.Resolvers.Member do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the member-related GraphQL calls
|
Handles the member-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.Actors
|
||||||
alias Mobilizon.Actors.{Actor}
|
alias Mobilizon.Actors.{Actor}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Person do
|
defmodule Mobilizon.GraphQL.Resolvers.Person do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the person-related GraphQL calls
|
Handles the person-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
@ -157,7 +157,7 @@ defmodule MobilizonWeb.Resolvers.Person do
|
|||||||
pic = args[key][:picture]
|
pic = args[key][:picture]
|
||||||
|
|
||||||
with {:ok, %{name: name, url: url, content_type: content_type, size: _size}} <-
|
with {:ok, %{name: name, url: url, content_type: content_type, size: _size}} <-
|
||||||
MobilizonWeb.Upload.store(pic.file, type: key, description: pic.alt) do
|
Mobilizon.Web.Upload.store(pic.file, type: key, description: pic.alt) do
|
||||||
Map.put(args, key, %{"name" => name, "url" => url, "mediaType" => content_type})
|
Map.put(args, key, %{"name" => name, "url" => url, "mediaType" => content_type})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -191,9 +191,11 @@ defmodule MobilizonWeb.Resolvers.Person do
|
|||||||
@doc """
|
@doc """
|
||||||
Returns the participation for a specific event
|
Returns the participation for a specific event
|
||||||
"""
|
"""
|
||||||
def person_participations(%Actor{id: actor_id}, %{event_id: event_id}, %{
|
def person_participations(
|
||||||
context: %{current_user: user}
|
%Actor{id: actor_id},
|
||||||
}) do
|
%{event_id: event_id},
|
||||||
|
%{context: %{current_user: user}}
|
||||||
|
) do
|
||||||
with {:is_owned, %Actor{} = _actor} <- User.owns_actor(user, actor_id),
|
with {:is_owned, %Actor{} = _actor} <- User.owns_actor(user, actor_id),
|
||||||
{:no_participant, {:ok, %Participant{} = participant}} <-
|
{:no_participant, {:ok, %Participant{} = participant}} <-
|
||||||
{:no_participant, Events.get_participant(event_id, actor_id)} do
|
{:no_participant, Events.get_participant(event_id, actor_id)} do
|
||||||
@ -234,7 +236,7 @@ defmodule MobilizonWeb.Resolvers.Person do
|
|||||||
|
|
||||||
@spec proxify_avatar(Actor.t()) :: Actor.t()
|
@spec proxify_avatar(Actor.t()) :: Actor.t()
|
||||||
defp proxify_avatar(%Actor{avatar: %{url: avatar_url} = avatar} = actor) do
|
defp proxify_avatar(%Actor{avatar: %{url: avatar_url} = avatar} = actor) do
|
||||||
actor |> Map.put(:avatar, avatar |> Map.put(:url, MobilizonWeb.MediaProxy.url(avatar_url)))
|
actor |> Map.put(:avatar, avatar |> Map.put(:url, Mobilizon.Web.MediaProxy.url(avatar_url)))
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec proxify_avatar(Actor.t()) :: Actor.t()
|
@spec proxify_avatar(Actor.t()) :: Actor.t()
|
||||||
@ -242,7 +244,7 @@ defmodule MobilizonWeb.Resolvers.Person do
|
|||||||
|
|
||||||
@spec proxify_banner(Actor.t()) :: Actor.t()
|
@spec proxify_banner(Actor.t()) :: Actor.t()
|
||||||
defp proxify_banner(%Actor{banner: %{url: banner_url} = banner} = actor) do
|
defp proxify_banner(%Actor{banner: %{url: banner_url} = banner} = actor) do
|
||||||
actor |> Map.put(:banner, banner |> Map.put(:url, MobilizonWeb.MediaProxy.url(banner_url)))
|
actor |> Map.put(:banner, banner |> Map.put(:url, Mobilizon.Web.MediaProxy.url(banner_url)))
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec proxify_banner(Actor.t()) :: Actor.t()
|
@spec proxify_banner(Actor.t()) :: Actor.t()
|
@ -1,7 +1,8 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Picture do
|
defmodule Mobilizon.GraphQL.Resolvers.Picture do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the picture-related GraphQL calls
|
Handles the picture-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.Media
|
alias Mobilizon.Media
|
||||||
alias Mobilizon.Media.Picture
|
alias Mobilizon.Media.Picture
|
||||||
@ -17,7 +18,7 @@ defmodule MobilizonWeb.Resolvers.Picture do
|
|||||||
@doc """
|
@doc """
|
||||||
Get picture for an event that has an attached
|
Get picture for an event that has an attached
|
||||||
|
|
||||||
See MobilizonWeb.Resolvers.Event.create_event/3
|
See Mobilizon.Web.Resolvers.Event.create_event/3
|
||||||
"""
|
"""
|
||||||
def picture(%{picture: picture} = _parent, _args, _resolution), do: {:ok, picture}
|
def picture(%{picture: picture} = _parent, _args, _resolution), do: {:ok, picture}
|
||||||
def picture(_parent, %{id: picture_id}, _resolution), do: do_fetch_picture(picture_id)
|
def picture(_parent, %{id: picture_id}, _resolution), do: do_fetch_picture(picture_id)
|
||||||
@ -44,7 +45,7 @@ defmodule MobilizonWeb.Resolvers.Picture do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec upload_picture(map(), map(), map()) :: {:ok, Picture.t()} | {:error, any()}
|
@spec upload_picture(map, map, map) :: {:ok, Picture.t()} | {:error, any}
|
||||||
def upload_picture(
|
def upload_picture(
|
||||||
_parent,
|
_parent,
|
||||||
%{file: %Plug.Upload{} = file, actor_id: actor_id} = args,
|
%{file: %Plug.Upload{} = file, actor_id: actor_id} = args,
|
||||||
@ -52,7 +53,7 @@ defmodule MobilizonWeb.Resolvers.Picture do
|
|||||||
) do
|
) do
|
||||||
with {:is_owned, %Actor{}} <- User.owns_actor(user, actor_id),
|
with {:is_owned, %Actor{}} <- User.owns_actor(user, actor_id),
|
||||||
{:ok, %{name: _name, url: url, content_type: content_type, size: size}} <-
|
{:ok, %{name: _name, url: url, content_type: content_type, size: size}} <-
|
||||||
MobilizonWeb.Upload.store(file),
|
Mobilizon.Web.Upload.store(file),
|
||||||
args <-
|
args <-
|
||||||
args
|
args
|
||||||
|> Map.put(:url, url)
|
|> Map.put(:url, url)
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Report do
|
defmodule Mobilizon.GraphQL.Resolvers.Report do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the report-related GraphQL calls.
|
Handles the report-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -11,7 +11,7 @@ defmodule MobilizonWeb.Resolvers.Report do
|
|||||||
alias Mobilizon.Reports.{Note, Report}
|
alias Mobilizon.Reports.{Note, Report}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.API.Reports, as: ReportsAPI
|
alias Mobilizon.GraphQL.API
|
||||||
|
|
||||||
def list_reports(
|
def list_reports(
|
||||||
_parent,
|
_parent,
|
||||||
@ -50,7 +50,7 @@ defmodule MobilizonWeb.Resolvers.Report do
|
|||||||
%{context: %{current_user: user}} = _resolution
|
%{context: %{current_user: user}} = _resolution
|
||||||
) do
|
) do
|
||||||
with {:is_owned, %Actor{}} <- User.owns_actor(user, reporter_id),
|
with {:is_owned, %Actor{}} <- User.owns_actor(user, reporter_id),
|
||||||
{:ok, _, %Report{} = report} <- ReportsAPI.report(args) do
|
{:ok, _, %Report{} = report} <- API.Reports.report(args) do
|
||||||
{:ok, report}
|
{:ok, report}
|
||||||
else
|
else
|
||||||
{:is_owned, nil} ->
|
{:is_owned, nil} ->
|
||||||
@ -76,8 +76,7 @@ defmodule MobilizonWeb.Resolvers.Report do
|
|||||||
when is_moderator(role) do
|
when is_moderator(role) do
|
||||||
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, moderator_id),
|
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, moderator_id),
|
||||||
%Report{} = report <- Mobilizon.Reports.get_report(report_id),
|
%Report{} = report <- Mobilizon.Reports.get_report(report_id),
|
||||||
{:ok, %Report{} = report} <-
|
{:ok, %Report{} = report} <- API.Reports.update_report_status(actor, report, status) do
|
||||||
MobilizonWeb.API.Reports.update_report_status(actor, report, status) do
|
|
||||||
{:ok, report}
|
{:ok, report}
|
||||||
else
|
else
|
||||||
{:is_owned, nil} ->
|
{:is_owned, nil} ->
|
||||||
@ -101,8 +100,7 @@ defmodule MobilizonWeb.Resolvers.Report do
|
|||||||
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
|
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
|
||||||
%Report{} = report <- Reports.get_report(report_id),
|
%Report{} = report <- Reports.get_report(report_id),
|
||||||
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
|
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
|
||||||
{:ok, %Note{} = note} <-
|
{:ok, %Note{} = note} <- API.Reports.create_report_note(report, moderator, content) do
|
||||||
MobilizonWeb.API.Reports.create_report_note(report, moderator, content) do
|
|
||||||
{:ok, note}
|
{:ok, note}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -116,8 +114,7 @@ defmodule MobilizonWeb.Resolvers.Report do
|
|||||||
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
|
with {:is_owned, %Actor{}} <- User.owns_actor(user, moderator_id),
|
||||||
%Note{} = note <- Reports.get_note(note_id),
|
%Note{} = note <- Reports.get_note(note_id),
|
||||||
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
|
%Actor{} = moderator <- Actors.get_local_actor_with_preload(moderator_id),
|
||||||
{:ok, %Note{} = note} <-
|
{:ok, %Note{} = note} <- API.Reports.delete_report_note(note, moderator) do
|
||||||
MobilizonWeb.API.Reports.delete_report_note(note, moderator) do
|
|
||||||
{:ok, %{id: note.id}}
|
{:ok, %{id: note.id}}
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,8 +1,9 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Search do
|
defmodule Mobilizon.GraphQL.Resolvers.Search do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the event-related GraphQL calls
|
Handles the event-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
alias MobilizonWeb.API.Search
|
|
||||||
|
alias Mobilizon.GraphQL.API.Search
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Search persons
|
Search persons
|
@ -1,10 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.Tag do
|
defmodule Mobilizon.GraphQL.Resolvers.Tag do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the tag-related GraphQL calls
|
Handles the tag-related GraphQL calls
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.Event
|
alias Mobilizon.Events.{Event, Tag}
|
||||||
alias Mobilizon.Events.Tag
|
|
||||||
|
|
||||||
def list_tags(_parent, %{page: page, limit: limit}, _resolution) do
|
def list_tags(_parent, %{page: page, limit: limit}, _resolution) do
|
||||||
tags = Mobilizon.Events.list_tags(page, limit)
|
tags = Mobilizon.Events.list_tags(page, limit)
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Resolvers.User do
|
defmodule Mobilizon.GraphQL.Resolvers.User do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the user-related GraphQL calls.
|
Handles the user-related GraphQL calls.
|
||||||
"""
|
"""
|
||||||
@ -10,7 +10,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
alias Mobilizon.Storage.Repo
|
alias Mobilizon.Storage.Repo
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.{Auth, Email}
|
alias Mobilizon.Web.{Auth, Email}
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -24,15 +24,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
@doc """
|
@doc """
|
||||||
Return current logged-in user
|
Return current logged-in user
|
||||||
"""
|
"""
|
||||||
def get_current_user(
|
def get_current_user(_parent, _args, %{context: %{current_user: user}}) do
|
||||||
_parent,
|
|
||||||
_args,
|
|
||||||
%{
|
|
||||||
context: %{
|
|
||||||
current_user: user
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) do
|
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,13 +38,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
def list_and_count_users(
|
def list_and_count_users(
|
||||||
_parent,
|
_parent,
|
||||||
%{page: page, limit: limit, sort: sort, direction: direction},
|
%{page: page, limit: limit, sort: sort, direction: direction},
|
||||||
%{
|
%{context: %{current_user: %User{role: role}}}
|
||||||
context: %{
|
|
||||||
current_user: %User{
|
|
||||||
role: role
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
when is_moderator(role) do
|
when is_moderator(role) do
|
||||||
total = Task.async(&Users.count_users/0)
|
total = Task.async(&Users.count_users/0)
|
||||||
@ -61,8 +47,9 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
{:ok, %{total: Task.await(total), elements: Task.await(elements)}}
|
{:ok, %{total: Task.await(total), elements: Task.await(elements)}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_and_count_users(_parent, _args, _resolution),
|
def list_and_count_users(_parent, _args, _resolution) do
|
||||||
do: {:error, "You need to have admin access to list users"}
|
{:error, "You need to have admin access to list users"}
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Login an user. Returns a token and the user
|
Login an user. Returns a token and the user
|
||||||
@ -87,13 +74,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
@doc """
|
@doc """
|
||||||
Refresh a token
|
Refresh a token
|
||||||
"""
|
"""
|
||||||
def refresh_token(
|
def refresh_token(_parent, %{refresh_token: refresh_token}, _context) do
|
||||||
_parent,
|
|
||||||
%{
|
|
||||||
refresh_token: refresh_token
|
|
||||||
},
|
|
||||||
_context
|
|
||||||
) do
|
|
||||||
with {:ok, user, _claims} <- Auth.Guardian.resource_from_token(refresh_token),
|
with {:ok, user, _claims} <- Auth.Guardian.resource_from_token(refresh_token),
|
||||||
{:ok, _old, {exchanged_token, _claims}} <-
|
{:ok, _old, {exchanged_token, _claims}} <-
|
||||||
Auth.Guardian.exchange(refresh_token, ["access", "refresh"], "access"),
|
Auth.Guardian.exchange(refresh_token, ["access", "refresh"], "access"),
|
||||||
@ -106,8 +87,9 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_token(_parent, _params, _context),
|
def refresh_token(_parent, _params, _context) do
|
||||||
do: {:error, "You need to have an existing token to get a refresh token"}
|
{:error, "You need to have an existing token to get a refresh token"}
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Register an user:
|
Register an user:
|
||||||
@ -115,7 +97,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
- create the user
|
- create the user
|
||||||
- send a validation email to the user
|
- send a validation email to the user
|
||||||
"""
|
"""
|
||||||
@spec create_user(any(), map(), any()) :: tuple()
|
@spec create_user(any, map, any) :: tuple
|
||||||
def create_user(_parent, args, _resolution) do
|
def create_user(_parent, args, _resolution) do
|
||||||
with :registration_ok <- check_registration_config(args),
|
with :registration_ok <- check_registration_config(args),
|
||||||
{:ok, %User{} = user} <- Users.register(args) do
|
{:ok, %User{} = user} <- Users.register(args) do
|
||||||
@ -133,7 +115,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec check_registration_config(map()) :: atom()
|
@spec check_registration_config(map) :: atom
|
||||||
defp check_registration_config(%{email: email}) do
|
defp check_registration_config(%{email: email}) do
|
||||||
cond do
|
cond do
|
||||||
Config.instance_registrations_open?() ->
|
Config.instance_registrations_open?() ->
|
||||||
@ -176,6 +158,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
error ->
|
error ->
|
||||||
Logger.info("Unable to validate user with token #{token}")
|
Logger.info("Unable to validate user with token #{token}")
|
||||||
Logger.debug(inspect(error))
|
Logger.debug(inspect(error))
|
||||||
|
|
||||||
{:error, "Unable to validate user"}
|
{:error, "Unable to validate user"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -253,9 +236,11 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
@doc """
|
@doc """
|
||||||
Returns the list of events for all of this user's identities are going to
|
Returns the list of events for all of this user's identities are going to
|
||||||
"""
|
"""
|
||||||
def user_participations(%User{id: user_id}, args, %{
|
def user_participations(
|
||||||
context: %{current_user: %User{id: logged_user_id}}
|
%User{id: user_id},
|
||||||
}) do
|
args,
|
||||||
|
%{context: %{current_user: %User{id: logged_user_id}}}
|
||||||
|
) do
|
||||||
with true <- user_id == logged_user_id,
|
with true <- user_id == logged_user_id,
|
||||||
participations <-
|
participations <-
|
||||||
Events.list_participations_for_user(
|
Events.list_participations_for_user(
|
||||||
@ -272,9 +257,11 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
@doc """
|
@doc """
|
||||||
Returns the list of draft events for the current user
|
Returns the list of draft events for the current user
|
||||||
"""
|
"""
|
||||||
def user_drafted_events(%User{id: user_id}, args, %{
|
def user_drafted_events(
|
||||||
context: %{current_user: %User{id: logged_user_id}}
|
%User{id: user_id},
|
||||||
}) do
|
args,
|
||||||
|
%{context: %{current_user: %User{id: logged_user_id}}}
|
||||||
|
) do
|
||||||
with {:same_user, true} <- {:same_user, user_id == logged_user_id},
|
with {:same_user, true} <- {:same_user, user_id == logged_user_id},
|
||||||
events <-
|
events <-
|
||||||
Events.list_drafts_for_user(user_id, Map.get(args, :page), Map.get(args, :limit)) do
|
Events.list_drafts_for_user(user_id, Map.get(args, :page), Map.get(args, :limit)) do
|
||||||
@ -282,17 +269,17 @@ defmodule MobilizonWeb.Resolvers.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_password(_parent, %{old_password: old_password, new_password: new_password}, %{
|
def change_password(
|
||||||
context: %{current_user: %User{password_hash: old_password_hash} = user}
|
_parent,
|
||||||
}) do
|
%{old_password: old_password, new_password: new_password},
|
||||||
|
%{context: %{current_user: %User{password_hash: old_password_hash} = user}}
|
||||||
|
) do
|
||||||
with {:current_password, true} <-
|
with {:current_password, true} <-
|
||||||
{:current_password, Argon2.verify_pass(old_password, old_password_hash)},
|
{:current_password, Argon2.verify_pass(old_password, old_password_hash)},
|
||||||
{:same_password, false} <- {:same_password, old_password == new_password},
|
{:same_password, false} <- {:same_password, old_password == new_password},
|
||||||
{:ok, %User{} = user} <-
|
{:ok, %User{} = user} <-
|
||||||
user
|
user
|
||||||
|> User.password_change_changeset(%{
|
|> User.password_change_changeset(%{"password" => new_password})
|
||||||
"password" => new_password
|
|
||||||
})
|
|
||||||
|> Repo.update() do
|
|> Repo.update() do
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
else
|
else
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema do
|
defmodule Mobilizon.GraphQL.Schema do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
GraphQL schema representation.
|
GraphQL schema representation.
|
||||||
"""
|
"""
|
||||||
@ -8,24 +8,25 @@ defmodule MobilizonWeb.Schema do
|
|||||||
alias Mobilizon.{Actors, Addresses, Events, Media, Reports, Users}
|
alias Mobilizon.{Actors, Addresses, Events, Media, Reports, Users}
|
||||||
alias Mobilizon.Actors.{Actor, Follower, Member}
|
alias Mobilizon.Actors.{Actor, Follower, Member}
|
||||||
alias Mobilizon.Events.{Comment, Event, Participant}
|
alias Mobilizon.Events.{Comment, Event, Participant}
|
||||||
|
alias Mobilizon.GraphQL.Schema
|
||||||
alias Mobilizon.Storage.Repo
|
alias Mobilizon.Storage.Repo
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.Custom.UUID)
|
|
||||||
import_types(MobilizonWeb.Schema.Custom.Point)
|
|
||||||
import_types(Absinthe.Type.Custom)
|
import_types(Absinthe.Type.Custom)
|
||||||
import_types(Absinthe.Plug.Types)
|
import_types(Absinthe.Plug.Types)
|
||||||
|
import_types(Schema.Custom.UUID)
|
||||||
|
import_types(Schema.Custom.Point)
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.UserType)
|
import_types(Schema.UserType)
|
||||||
import_types(MobilizonWeb.Schema.PictureType)
|
import_types(Schema.PictureType)
|
||||||
import_types(MobilizonWeb.Schema.ActorInterface)
|
import_types(Schema.ActorInterface)
|
||||||
import_types(MobilizonWeb.Schema.Actors.PersonType)
|
import_types(Schema.Actors.PersonType)
|
||||||
import_types(MobilizonWeb.Schema.Actors.GroupType)
|
import_types(Schema.Actors.GroupType)
|
||||||
import_types(MobilizonWeb.Schema.Actors.ApplicationType)
|
import_types(Schema.Actors.ApplicationType)
|
||||||
import_types(MobilizonWeb.Schema.CommentType)
|
import_types(Schema.CommentType)
|
||||||
import_types(MobilizonWeb.Schema.SearchType)
|
import_types(Schema.SearchType)
|
||||||
import_types(MobilizonWeb.Schema.ConfigType)
|
import_types(Schema.ConfigType)
|
||||||
import_types(MobilizonWeb.Schema.ReportType)
|
import_types(Schema.ReportType)
|
||||||
import_types(MobilizonWeb.Schema.AdminType)
|
import_types(Schema.AdminType)
|
||||||
|
|
||||||
@desc "A struct containing the id of the deleted object"
|
@desc "A struct containing the id of the deleted object"
|
||||||
object :deleted_object do
|
object :deleted_object do
|
@ -1,12 +1,14 @@
|
|||||||
defmodule MobilizonWeb.Schema.ActorInterface do
|
defmodule Mobilizon.GraphQL.Schema.ActorInterface do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Actor
|
Schema representation for Actor
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias Mobilizon.Actors.Actor
|
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.Actors.FollowerType)
|
alias Mobilizon.Actors.Actor
|
||||||
import_types(MobilizonWeb.Schema.EventType)
|
alias Mobilizon.GraphQL.Schema
|
||||||
|
|
||||||
|
import_types(Schema.Actors.FollowerType)
|
||||||
|
import_types(Schema.EventType)
|
||||||
|
|
||||||
@desc "An ActivityPub actor"
|
@desc "An ActivityPub actor"
|
||||||
interface :actor do
|
interface :actor do
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Actors.ApplicationType do
|
defmodule Mobilizon.GraphQL.Schema.Actors.ApplicationType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Group.
|
Schema representation for Group.
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Actors.FollowerType do
|
defmodule Mobilizon.GraphQL.Schema.Actors.FollowerType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Follower
|
Schema representation for Follower
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Actors.GroupType do
|
defmodule Mobilizon.GraphQL.Schema.Actors.GroupType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Group.
|
Schema representation for Group.
|
||||||
"""
|
"""
|
||||||
@ -8,10 +8,10 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
|
|||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.{Group, Member}
|
||||||
|
alias Mobilizon.GraphQL.Schema
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers.{Group, Member}
|
import_types(Schema.Actors.MemberType)
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.Actors.MemberType)
|
|
||||||
|
|
||||||
@desc """
|
@desc """
|
||||||
Represents a group of actors
|
Represents a group of actors
|
@ -1,10 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.Actors.MemberType do
|
defmodule Mobilizon.GraphQL.Schema.Actors.MemberType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Member
|
Schema representation for Member
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers
|
alias Mobilizon.GraphQL.Resolvers.Group
|
||||||
|
|
||||||
@desc """
|
@desc """
|
||||||
Represents a member of a group
|
Represents a member of a group
|
||||||
@ -27,7 +27,7 @@ defmodule MobilizonWeb.Schema.Actors.MemberType do
|
|||||||
arg(:group_id, non_null(:id))
|
arg(:group_id, non_null(:id))
|
||||||
arg(:actor_id, non_null(:id))
|
arg(:actor_id, non_null(:id))
|
||||||
|
|
||||||
resolve(&Resolvers.Group.join_group/3)
|
resolve(&Group.join_group/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Leave an event"
|
@desc "Leave an event"
|
||||||
@ -35,7 +35,7 @@ defmodule MobilizonWeb.Schema.Actors.MemberType do
|
|||||||
arg(:group_id, non_null(:id))
|
arg(:group_id, non_null(:id))
|
||||||
arg(:actor_id, non_null(:id))
|
arg(:actor_id, non_null(:id))
|
||||||
|
|
||||||
resolve(&Resolvers.Group.leave_group/3)
|
resolve(&Group.leave_group/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,14 +1,17 @@
|
|||||||
defmodule MobilizonWeb.Schema.Actors.PersonType do
|
defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Person
|
Schema representation for Person
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
|
||||||
alias Mobilizon.Events
|
|
||||||
alias MobilizonWeb.Resolvers.Person
|
|
||||||
import MobilizonWeb.Schema.Utils
|
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.Events.FeedTokenType)
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
import Mobilizon.GraphQL.Helpers.Error
|
||||||
|
|
||||||
|
alias Mobilizon.Events
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Person
|
||||||
|
alias Mobilizon.GraphQL.Schema
|
||||||
|
|
||||||
|
import_types(Schema.Events.FeedTokenType)
|
||||||
|
|
||||||
@desc """
|
@desc """
|
||||||
Represents a person identity
|
Represents a person identity
|
@ -1,9 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.AddressType do
|
defmodule Mobilizon.GraphQL.Schema.AddressType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Address
|
Schema representation for Address
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias MobilizonWeb.Resolvers
|
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Address
|
||||||
|
|
||||||
object :address do
|
object :address do
|
||||||
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
||||||
@ -52,7 +53,7 @@ defmodule MobilizonWeb.Schema.AddressType do
|
|||||||
arg(:page, :integer, default_value: 1)
|
arg(:page, :integer, default_value: 1)
|
||||||
arg(:limit, :integer, default_value: 10)
|
arg(:limit, :integer, default_value: 10)
|
||||||
|
|
||||||
resolve(&Resolvers.Address.search/3)
|
resolve(&Address.search/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Reverse geocode coordinates"
|
@desc "Reverse geocode coordinates"
|
||||||
@ -62,7 +63,7 @@ defmodule MobilizonWeb.Schema.AddressType do
|
|||||||
arg(:zoom, :integer, default_value: 15)
|
arg(:zoom, :integer, default_value: 15)
|
||||||
arg(:locale, :string, default_value: "en")
|
arg(:locale, :string, default_value: "en")
|
||||||
|
|
||||||
resolve(&Resolvers.Address.reverse_geocode/3)
|
resolve(&Address.reverse_geocode/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.AdminType do
|
defmodule Mobilizon.GraphQL.Schema.AdminType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for ActionLog.
|
Schema representation for ActionLog.
|
||||||
"""
|
"""
|
||||||
@ -8,7 +8,7 @@ defmodule MobilizonWeb.Schema.AdminType do
|
|||||||
alias Mobilizon.Events.{Event, Comment}
|
alias Mobilizon.Events.{Event, Comment}
|
||||||
alias Mobilizon.Reports.{Note, Report}
|
alias Mobilizon.Reports.{Note, Report}
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers.Admin
|
alias Mobilizon.GraphQL.Resolvers.Admin
|
||||||
|
|
||||||
@desc "An action log"
|
@desc "An action log"
|
||||||
object :action_log do
|
object :action_log do
|
@ -1,12 +1,14 @@
|
|||||||
defmodule MobilizonWeb.Schema.CommentType do
|
defmodule Mobilizon.GraphQL.Schema.CommentType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Comment
|
Schema representation for Comment
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias MobilizonWeb.Resolvers.Comment
|
|
||||||
alias Mobilizon.{Actors, Events}
|
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
|
||||||
|
alias Mobilizon.{Actors, Events}
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Comment
|
||||||
|
|
||||||
@desc "A comment"
|
@desc "A comment"
|
||||||
object :comment do
|
object :comment do
|
||||||
interfaces([:action_log_object])
|
interfaces([:action_log_object])
|
@ -1,10 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.ConfigType do
|
defmodule Mobilizon.GraphQL.Schema.ConfigType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for User
|
Schema representation for User
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers.Config
|
alias Mobilizon.GraphQL.Resolvers.Config
|
||||||
|
|
||||||
@desc "A config object"
|
@desc "A config object"
|
||||||
object :config do
|
object :config do
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Custom.Point do
|
defmodule Mobilizon.GraphQL.Schema.Custom.Point do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
The geom scalar type allows Geo.PostGIS.Geometry strings to be passed in and out.
|
The geom scalar type allows Geo.PostGIS.Geometry strings to be passed in and out.
|
||||||
Requires `{:geo, "~> 3.0"},` package: https://github.com/elixir-ecto/ecto
|
Requires `{:geo, "~> 3.0"},` package: https://github.com/elixir-ecto/ecto
|
||||||
@ -15,7 +15,7 @@ defmodule MobilizonWeb.Schema.Custom.Point do
|
|||||||
parse(&decode/1)
|
parse(&decode/1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term()} | :error
|
@spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term} | :error
|
||||||
@spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
|
@spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
|
||||||
defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
|
defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
|
||||||
with [_, _] = lonlat <- String.split(value, ";", trim: true),
|
with [_, _] = lonlat <- String.split(value, ";", trim: true),
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Custom.UUID do
|
defmodule Mobilizon.GraphQL.Schema.Custom.UUID do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
The UUID4 scalar type allows UUID compliant strings to be passed in and out.
|
The UUID4 scalar type allows UUID compliant strings to be passed in and out.
|
||||||
Requires `{ :ecto, ">= 0.0.0" }` package: https://github.com/elixir-ecto/ecto
|
Requires `{ :ecto, ">= 0.0.0" }` package: https://github.com/elixir-ecto/ecto
|
||||||
@ -18,7 +18,7 @@ defmodule MobilizonWeb.Schema.Custom.UUID do
|
|||||||
parse(&decode/1)
|
parse(&decode/1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term()} | :error
|
@spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term} | :error
|
||||||
@spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
|
@spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
|
||||||
defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
|
defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
|
||||||
UUID.cast(value)
|
UUID.cast(value)
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.EventType do
|
defmodule Mobilizon.GraphQL.Schema.EventType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Event.
|
Schema representation for Event.
|
||||||
"""
|
"""
|
||||||
@ -6,15 +6,15 @@ defmodule MobilizonWeb.Schema.EventType do
|
|||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
|
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
import MobilizonWeb.Schema.Utils
|
import Mobilizon.GraphQL.Helpers.Error
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Addresses, Events}
|
alias Mobilizon.{Actors, Addresses, Events}
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.{Event, Picture, Tag}
|
||||||
|
alias Mobilizon.GraphQL.Schema
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers.{Event, Picture, Tag}
|
import_types(Schema.AddressType)
|
||||||
|
import_types(Schema.Events.ParticipantType)
|
||||||
import_types(MobilizonWeb.Schema.AddressType)
|
import_types(Schema.TagType)
|
||||||
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
|
||||||
import_types(MobilizonWeb.Schema.TagType)
|
|
||||||
|
|
||||||
@desc "An event"
|
@desc "An event"
|
||||||
object :event do
|
object :event do
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Events.FeedTokenType do
|
defmodule Mobilizon.GraphQL.Schema.Events.FeedTokenType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Participant.
|
Schema representation for Participant.
|
||||||
"""
|
"""
|
||||||
@ -8,8 +8,7 @@ defmodule MobilizonWeb.Schema.Events.FeedTokenType do
|
|||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Users}
|
alias Mobilizon.{Actors, Users}
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.FeedToken
|
||||||
alias MobilizonWeb.Resolvers
|
|
||||||
|
|
||||||
@desc "Represents a participant to an event"
|
@desc "Represents a participant to an event"
|
||||||
object :feed_token do
|
object :feed_token do
|
||||||
@ -41,14 +40,14 @@ defmodule MobilizonWeb.Schema.Events.FeedTokenType do
|
|||||||
field :create_feed_token, :feed_token do
|
field :create_feed_token, :feed_token do
|
||||||
arg(:actor_id, :id)
|
arg(:actor_id, :id)
|
||||||
|
|
||||||
resolve(&Resolvers.FeedToken.create_feed_token/3)
|
resolve(&FeedToken.create_feed_token/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Delete a feed token"
|
@desc "Delete a feed token"
|
||||||
field :delete_feed_token, :deleted_feed_token do
|
field :delete_feed_token, :deleted_feed_token do
|
||||||
arg(:token, non_null(:string))
|
arg(:token, non_null(:string))
|
||||||
|
|
||||||
resolve(&Resolvers.FeedToken.delete_feed_token/3)
|
resolve(&FeedToken.delete_feed_token/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Participant.
|
Schema representation for Participant.
|
||||||
"""
|
"""
|
||||||
@ -8,8 +8,7 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
|||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Events}
|
alias Mobilizon.{Actors, Events}
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Event
|
||||||
alias MobilizonWeb.Resolvers
|
|
||||||
|
|
||||||
@desc "Represents a participant to an event"
|
@desc "Represents a participant to an event"
|
||||||
object :participant do
|
object :participant do
|
||||||
@ -54,7 +53,7 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
|||||||
arg(:event_id, non_null(:id))
|
arg(:event_id, non_null(:id))
|
||||||
arg(:actor_id, non_null(:id))
|
arg(:actor_id, non_null(:id))
|
||||||
|
|
||||||
resolve(&Resolvers.Event.actor_join_event/3)
|
resolve(&Event.actor_join_event/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Leave an event"
|
@desc "Leave an event"
|
||||||
@ -62,7 +61,7 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
|||||||
arg(:event_id, non_null(:id))
|
arg(:event_id, non_null(:id))
|
||||||
arg(:actor_id, non_null(:id))
|
arg(:actor_id, non_null(:id))
|
||||||
|
|
||||||
resolve(&Resolvers.Event.actor_leave_event/3)
|
resolve(&Event.actor_leave_event/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Accept a participation"
|
@desc "Accept a participation"
|
||||||
@ -71,7 +70,7 @@ defmodule MobilizonWeb.Schema.Events.ParticipantType do
|
|||||||
arg(:role, non_null(:participant_role_enum))
|
arg(:role, non_null(:participant_role_enum))
|
||||||
arg(:moderator_actor_id, non_null(:id))
|
arg(:moderator_actor_id, non_null(:id))
|
||||||
|
|
||||||
resolve(&Resolvers.Event.update_participation/3)
|
resolve(&Event.update_participation/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,9 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.PictureType do
|
defmodule Mobilizon.GraphQL.Schema.PictureType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Pictures
|
Schema representation for Pictures
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias MobilizonWeb.Resolvers.Picture
|
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Picture
|
||||||
|
|
||||||
@desc "A picture"
|
@desc "A picture"
|
||||||
object :picture do
|
object :picture do
|
@ -1,12 +1,13 @@
|
|||||||
defmodule MobilizonWeb.Schema.ReportType do
|
defmodule Mobilizon.GraphQL.Schema.ReportType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for User
|
Schema representation for User
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
|
||||||
alias Mobilizon.Reports
|
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers.Report
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
|
||||||
|
alias Mobilizon.Reports
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Report
|
||||||
|
|
||||||
@desc "A report object"
|
@desc "A report object"
|
||||||
object :report do
|
object :report do
|
@ -1,10 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.SearchType do
|
defmodule Mobilizon.GraphQL.Schema.SearchType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Search
|
Schema representation for Search
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
|
|
||||||
alias MobilizonWeb.Resolvers
|
alias Mobilizon.GraphQL.Resolvers.Search
|
||||||
|
|
||||||
@desc "Search persons result"
|
@desc "Search persons result"
|
||||||
object :persons do
|
object :persons do
|
||||||
@ -31,7 +31,7 @@ defmodule MobilizonWeb.Schema.SearchType do
|
|||||||
arg(:page, :integer, default_value: 1)
|
arg(:page, :integer, default_value: 1)
|
||||||
arg(:limit, :integer, default_value: 10)
|
arg(:limit, :integer, default_value: 10)
|
||||||
|
|
||||||
resolve(&Resolvers.Search.search_persons/3)
|
resolve(&Search.search_persons/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Search groups"
|
@desc "Search groups"
|
||||||
@ -40,7 +40,7 @@ defmodule MobilizonWeb.Schema.SearchType do
|
|||||||
arg(:page, :integer, default_value: 1)
|
arg(:page, :integer, default_value: 1)
|
||||||
arg(:limit, :integer, default_value: 10)
|
arg(:limit, :integer, default_value: 10)
|
||||||
|
|
||||||
resolve(&Resolvers.Search.search_groups/3)
|
resolve(&Search.search_groups/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Search events"
|
@desc "Search events"
|
||||||
@ -49,7 +49,7 @@ defmodule MobilizonWeb.Schema.SearchType do
|
|||||||
arg(:page, :integer, default_value: 1)
|
arg(:page, :integer, default_value: 1)
|
||||||
arg(:limit, :integer, default_value: 10)
|
arg(:limit, :integer, default_value: 10)
|
||||||
|
|
||||||
resolve(&Resolvers.Search.search_events/3)
|
resolve(&Search.search_events/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Schema.SortType do
|
defmodule Mobilizon.GraphQL.Schema.SortType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Allows sorting a collection of elements
|
Allows sorting a collection of elements
|
||||||
"""
|
"""
|
@ -1,9 +1,10 @@
|
|||||||
defmodule MobilizonWeb.Schema.TagType do
|
defmodule Mobilizon.GraphQL.Schema.TagType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for Tags
|
Schema representation for Tags
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias MobilizonWeb.Resolvers
|
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.Tag
|
||||||
|
|
||||||
@desc "A tag"
|
@desc "A tag"
|
||||||
object :tag do
|
object :tag do
|
||||||
@ -14,7 +15,7 @@ defmodule MobilizonWeb.Schema.TagType do
|
|||||||
field(
|
field(
|
||||||
:related,
|
:related,
|
||||||
list_of(:tag),
|
list_of(:tag),
|
||||||
resolve: &Resolvers.Tag.get_related_tags/3,
|
resolve: &Tag.get_related_tags/3,
|
||||||
description: "Related tags to this tag"
|
description: "Related tags to this tag"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@ -24,7 +25,7 @@ defmodule MobilizonWeb.Schema.TagType do
|
|||||||
field :tags, non_null(list_of(:tag)) do
|
field :tags, non_null(list_of(:tag)) do
|
||||||
arg(:page, :integer, default_value: 1)
|
arg(:page, :integer, default_value: 1)
|
||||||
arg(:limit, :integer, default_value: 10)
|
arg(:limit, :integer, default_value: 10)
|
||||||
resolve(&Resolvers.Tag.list_tags/3)
|
resolve(&Tag.list_tags/3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,14 +1,17 @@
|
|||||||
defmodule MobilizonWeb.Schema.UserType do
|
defmodule Mobilizon.GraphQL.Schema.UserType do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Schema representation for User
|
Schema representation for User
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
|
||||||
alias Mobilizon.Events
|
|
||||||
alias MobilizonWeb.Resolvers.User
|
|
||||||
import MobilizonWeb.Schema.Utils
|
|
||||||
|
|
||||||
import_types(MobilizonWeb.Schema.SortType)
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
|
import Mobilizon.GraphQL.Helpers.Error
|
||||||
|
|
||||||
|
alias Mobilizon.Events
|
||||||
|
alias Mobilizon.GraphQL.Resolvers.User
|
||||||
|
alias Mobilizon.GraphQL.Schema
|
||||||
|
|
||||||
|
import_types(Schema.SortType)
|
||||||
|
|
||||||
@desc "A local user of Mobilizon"
|
@desc "A local user of Mobilizon"
|
||||||
object :user do
|
object :user do
|
@ -7,11 +7,12 @@ defmodule Mix.Tasks.Mobilizon.MoveParticipantStats do
|
|||||||
|
|
||||||
use Mix.Task
|
use Mix.Task
|
||||||
|
|
||||||
alias Mobilizon.Storage.Repo
|
import Ecto.Query
|
||||||
|
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.Event
|
alias Mobilizon.Events.Event
|
||||||
alias Mobilizon.Events.ParticipantRole
|
alias Mobilizon.Events.ParticipantRole
|
||||||
import Ecto.Query
|
alias Mobilizon.Storage.Repo
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ defmodule Mix.Tasks.Mobilizon.Relay do
|
|||||||
use Mix.Task
|
use Mix.Task
|
||||||
|
|
||||||
alias Mix.Tasks.Mobilizon.Common
|
alias Mix.Tasks.Mobilizon.Common
|
||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub.Relay
|
alias Mobilizon.Federation.ActivityPub.Relay
|
||||||
|
|
||||||
@shortdoc "Manages remote relays"
|
@shortdoc "Manages remote relays"
|
||||||
|
@ -5,10 +5,11 @@ defmodule Mix.Tasks.Mobilizon.Toot do
|
|||||||
|
|
||||||
use Mix.Task
|
use Mix.Task
|
||||||
|
|
||||||
alias MobilizonWeb.API.Comments
|
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.Actors
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
|
||||||
|
alias Mobilizon.GraphQL.API.Comments
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@shortdoc "Toot to an user"
|
@shortdoc "Toot to an user"
|
||||||
|
@ -26,7 +26,7 @@ defmodule Mobilizon do
|
|||||||
|
|
||||||
@spec user_agent :: String.t()
|
@spec user_agent :: String.t()
|
||||||
def user_agent do
|
def user_agent do
|
||||||
info = "#{MobilizonWeb.Endpoint.url()} <#{Config.get([:instance, :email], "")}>"
|
info = "#{Mobilizon.Web.Endpoint.url()} <#{Config.get([:instance, :email], "")}>"
|
||||||
|
|
||||||
"#{named_version()}; #{info}"
|
"#{named_version()}; #{info}"
|
||||||
end
|
end
|
||||||
@ -37,8 +37,8 @@ defmodule Mobilizon do
|
|||||||
children = [
|
children = [
|
||||||
# supervisors
|
# supervisors
|
||||||
Mobilizon.Storage.Repo,
|
Mobilizon.Storage.Repo,
|
||||||
MobilizonWeb.Endpoint,
|
Mobilizon.Web.Endpoint,
|
||||||
{Absinthe.Subscription, [MobilizonWeb.Endpoint]},
|
{Absinthe.Subscription, [Mobilizon.Web.Endpoint]},
|
||||||
{Oban, Application.get_env(:mobilizon, Oban)},
|
{Oban, Application.get_env(:mobilizon, Oban)},
|
||||||
# workers
|
# workers
|
||||||
Guardian.DB.Token.SweeperServer,
|
Guardian.DB.Token.SweeperServer,
|
||||||
@ -55,7 +55,7 @@ defmodule Mobilizon do
|
|||||||
|
|
||||||
@spec config_change(keyword, keyword, [atom]) :: :ok
|
@spec config_change(keyword, keyword, [atom]) :: :ok
|
||||||
def config_change(changed, _new, removed) do
|
def config_change(changed, _new, removed) do
|
||||||
MobilizonWeb.Endpoint.config_change(changed, removed)
|
Mobilizon.Web.Endpoint.config_change(changed, removed)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
@ -15,8 +15,8 @@ defmodule Mobilizon.Actors.Actor do
|
|||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
alias Mobilizon.Mention
|
alias Mobilizon.Mention
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ defmodule Mobilizon.Actors.Actor do
|
|||||||
|> put_change(:followers_url, build_url(username, :followers))
|
|> put_change(:followers_url, build_url(username, :followers))
|
||||||
|> put_change(:following_url, build_url(username, :following))
|
|> put_change(:following_url, build_url(username, :following))
|
||||||
|> put_change(:inbox_url, build_url(username, :inbox))
|
|> put_change(:inbox_url, build_url(username, :inbox))
|
||||||
|> put_change(:shared_inbox_url, "#{MobilizonWeb.Endpoint.url()}/inbox")
|
|> put_change(:shared_inbox_url, "#{Mobilizon.Web.Endpoint.url()}/inbox")
|
||||||
|> put_change(:url, build_url(username, :page))
|
|> put_change(:url, build_url(username, :page))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -376,10 +376,10 @@ defmodule Mobilizon.Actors.Actor do
|
|||||||
"keys" => Crypto.generate_rsa_2048_private_key(),
|
"keys" => Crypto.generate_rsa_2048_private_key(),
|
||||||
"preferred_username" => preferred_username,
|
"preferred_username" => preferred_username,
|
||||||
"domain" => nil,
|
"domain" => nil,
|
||||||
"inbox_url" => "#{MobilizonWeb.Endpoint.url()}/inbox",
|
"inbox_url" => "#{Mobilizon.Web.Endpoint.url()}/inbox",
|
||||||
"followers_url" => "#{url}/followers",
|
"followers_url" => "#{url}/followers",
|
||||||
"following_url" => "#{url}/following",
|
"following_url" => "#{url}/following",
|
||||||
"shared_inbox_url" => "#{MobilizonWeb.Endpoint.url()}/inbox",
|
"shared_inbox_url" => "#{Mobilizon.Web.Endpoint.url()}/inbox",
|
||||||
"type" => :Application
|
"type" => :Application
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -755,7 +755,7 @@ defmodule Mobilizon.Actors do
|
|||||||
|
|
||||||
@spec safe_remove_file(String.t(), Actor.t()) :: {:ok, Actor.t()}
|
@spec safe_remove_file(String.t(), Actor.t()) :: {:ok, Actor.t()}
|
||||||
defp safe_remove_file(url, %Actor{} = actor) do
|
defp safe_remove_file(url, %Actor{} = actor) do
|
||||||
case MobilizonWeb.Upload.remove(url) do
|
case Mobilizon.Web.Upload.remove(url) do
|
||||||
{:ok, _value} ->
|
{:ok, _value} ->
|
||||||
{:ok, actor}
|
{:ok, actor}
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ defmodule Mobilizon.Actors do
|
|||||||
with %Ecto.Changeset{changes: %{url: new_url}} <- changes[key],
|
with %Ecto.Changeset{changes: %{url: new_url}} <- changes[key],
|
||||||
%{url: old_url} <- data |> Map.from_struct() |> Map.get(key),
|
%{url: old_url} <- data |> Map.from_struct() |> Map.get(key),
|
||||||
false <- new_url == old_url do
|
false <- new_url == old_url do
|
||||||
MobilizonWeb.Upload.remove(old_url)
|
Mobilizon.Web.Upload.remove(old_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -65,6 +65,6 @@ defmodule Mobilizon.Actors.Follower do
|
|||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> put_change(:id, uuid)
|
|> put_change(:id, uuid)
|
||||||
|> put_change(:url, "#{MobilizonWeb.Endpoint.url()}/follow/#{uuid}")
|
|> put_change(:url, "#{Mobilizon.Web.Endpoint.url()}/follow/#{uuid}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,8 @@ defmodule Mobilizon.Addresses.Address do
|
|||||||
|
|
||||||
@spec set_url(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
@spec set_url(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||||
defp set_url(%Ecto.Changeset{changes: changes} = changeset) do
|
defp set_url(%Ecto.Changeset{changes: changes} = changeset) do
|
||||||
url = Map.get(changes, :url, "#{MobilizonWeb.Endpoint.url()}/address/#{Ecto.UUID.generate()}")
|
url =
|
||||||
|
Map.get(changes, :url, "#{Mobilizon.Web.Endpoint.url()}/address/#{Ecto.UUID.generate()}")
|
||||||
|
|
||||||
put_change(changeset, :url, url)
|
put_change(changeset, :url, url)
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,8 @@ defmodule Mobilizon.Events.Comment do
|
|||||||
alias Mobilizon.Events.{Comment, CommentVisibility, Event, Tag}
|
alias Mobilizon.Events.{Comment, CommentVisibility, Event, Tag}
|
||||||
alias Mobilizon.Mention
|
alias Mobilizon.Mention
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
text: String.t(),
|
text: String.t(),
|
||||||
|
@ -33,8 +33,8 @@ defmodule Mobilizon.Events.Event do
|
|||||||
alias Mobilizon.Mention
|
alias Mobilizon.Mention
|
||||||
alias Mobilizon.Storage.Repo
|
alias Mobilizon.Storage.Repo
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
url: String.t(),
|
url: String.t(),
|
||||||
|
@ -31,7 +31,7 @@ defmodule Mobilizon.Events do
|
|||||||
alias Mobilizon.Storage.{Page, Repo}
|
alias Mobilizon.Storage.{Page, Repo}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
defenum(EventVisibility, :event_visibility, [
|
defenum(EventVisibility, :event_visibility, [
|
||||||
:public,
|
:public,
|
||||||
|
@ -11,7 +11,7 @@ defmodule Mobilizon.Events.Participant do
|
|||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.{Event, ParticipantRole}
|
alias Mobilizon.Events.{Event, ParticipantRole}
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
role: ParticipantRole.t(),
|
role: ParticipantRole.t(),
|
||||||
|
@ -62,7 +62,7 @@ defmodule Mobilizon.Media do
|
|||||||
Multi.new()
|
Multi.new()
|
||||||
|> Multi.delete(:picture, picture)
|
|> Multi.delete(:picture, picture)
|
||||||
|> Multi.run(:remove, fn _repo, %{picture: %Picture{file: %File{url: url}}} ->
|
|> Multi.run(:remove, fn _repo, %{picture: %Picture{file: %File{url: url}}} ->
|
||||||
MobilizonWeb.Upload.remove(url)
|
Mobilizon.Web.Upload.remove(url)
|
||||||
end)
|
end)
|
||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ defmodule Mobilizon.Reports.Report do
|
|||||||
@spec maybe_generate_url(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
@spec maybe_generate_url(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||||
defp maybe_generate_url(%Ecto.Changeset{} = changeset) do
|
defp maybe_generate_url(%Ecto.Changeset{} = changeset) do
|
||||||
with res when res in [:error, {:data, nil}] <- fetch_field(changeset, :url),
|
with res when res in [:error, {:data, nil}] <- fetch_field(changeset, :url),
|
||||||
url <- "#{MobilizonWeb.Endpoint.url()}/report/#{Ecto.UUID.generate()}" do
|
url <- "#{Mobilizon.Web.Endpoint.url()}/report/#{Ecto.UUID.generate()}" do
|
||||||
put_change(changeset, :url, url)
|
put_change(changeset, :url, url)
|
||||||
else
|
else
|
||||||
_ -> changeset
|
_ -> changeset
|
||||||
|
@ -12,7 +12,7 @@ defmodule Mobilizon.Users.User do
|
|||||||
alias Mobilizon.Events.FeedToken
|
alias Mobilizon.Events.FeedToken
|
||||||
alias Mobilizon.Users.UserRole
|
alias Mobilizon.Users.UserRole
|
||||||
|
|
||||||
alias MobilizonWeb.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
email: String.t(),
|
email: String.t(),
|
||||||
|
@ -13,7 +13,7 @@ defmodule Mobilizon.Users do
|
|||||||
alias Mobilizon.Storage.{Page, Repo}
|
alias Mobilizon.Storage.{Page, Repo}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.Auth
|
alias Mobilizon.Web.Auth
|
||||||
|
|
||||||
@type tokens :: %{
|
@type tokens :: %{
|
||||||
required(:access_token) => String.t(),
|
required(:access_token) => String.t(),
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
defmodule MobilizonWeb.LayoutView do
|
|
||||||
use MobilizonWeb, :view
|
|
||||||
end
|
|
@ -3,7 +3,7 @@ defmodule Mobilizon.Service.Export.Feed do
|
|||||||
Serve Atom Syndication Feeds.
|
Serve Atom Syndication Feeds.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import MobilizonWeb.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
alias Atomex.{Entry, Feed}
|
alias Atomex.{Entry, Feed}
|
||||||
|
|
||||||
@ -12,8 +12,8 @@ defmodule Mobilizon.Service.Export.Feed do
|
|||||||
alias Mobilizon.Events.{Event, FeedToken}
|
alias Mobilizon.Events.{Event, FeedToken}
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.{Endpoint, MediaProxy}
|
alias Mobilizon.Web.{Endpoint, MediaProxy}
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ defmodule Mobilizon.Service.Export.Feed do
|
|||||||
self_url
|
self_url
|
||||||
|> Feed.new(
|
|> Feed.new(
|
||||||
DateTime.utc_now(),
|
DateTime.utc_now(),
|
||||||
Gettext.gettext(MobilizonWeb.Gettext, title, actor: display_name)
|
Gettext.gettext(Mobilizon.Web.Gettext, title, actor: display_name)
|
||||||
)
|
)
|
||||||
|> Feed.author(display_name, uri: actor.url)
|
|> Feed.author(display_name, uri: actor.url)
|
||||||
|> Feed.link(self_url, rel: "self")
|
|> Feed.link(self_url, rel: "self")
|
||||||
|
@ -52,7 +52,7 @@ defmodule Mobilizon.Service.Formatter do
|
|||||||
|
|
||||||
def hashtag_handler("#" <> tag = tag_text, _buffer, _opts, acc) do
|
def hashtag_handler("#" <> tag = tag_text, _buffer, _opts, acc) do
|
||||||
tag = String.downcase(tag)
|
tag = String.downcase(tag)
|
||||||
url = "#{MobilizonWeb.Endpoint.url()}/tag/#{tag}"
|
url = "#{Mobilizon.Web.Endpoint.url()}/tag/#{tag}"
|
||||||
link = "<a class='hashtag' data-tag='#{tag}' href='#{url}' rel='tag'>#{tag_text}</a>"
|
link = "<a class='hashtag' data-tag='#{tag}' href='#{url}' rel='tag'>#{tag_text}</a>"
|
||||||
|
|
||||||
{link, %{acc | tags: MapSet.put(acc.tags, {tag_text, tag})}}
|
{link, %{acc | tags: MapSet.put(acc.tags, {tag_text, tag})}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Actors.Actor do
|
||||||
alias Phoenix.HTML.Tag
|
alias Phoenix.HTML.Tag
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias MobilizonWeb.MediaProxy
|
alias Mobilizon.Web.MediaProxy
|
||||||
|
|
||||||
def build_tags(%Actor{} = actor) do
|
def build_tags(%Actor{} = actor) do
|
||||||
tags = [
|
tags = [
|
||||||
|
@ -2,8 +2,8 @@ defimpl Mobilizon.Service.Metadata, for: Mobilizon.Events.Event do
|
|||||||
alias Phoenix.HTML
|
alias Phoenix.HTML
|
||||||
alias Phoenix.HTML.Tag
|
alias Phoenix.HTML.Tag
|
||||||
alias Mobilizon.Events.Event
|
alias Mobilizon.Events.Event
|
||||||
alias MobilizonWeb.JsonLD.ObjectView
|
alias Mobilizon.Web.JsonLD.ObjectView
|
||||||
alias MobilizonWeb.MediaProxy
|
alias Mobilizon.Web.MediaProxy
|
||||||
|
|
||||||
def build_tags(%Event{} = event) do
|
def build_tags(%Event{} = event) do
|
||||||
event = Map.put(event, :description, process_description(event.description))
|
event = Map.put(event, :description, process_description(event.description))
|
||||||
|
@ -6,7 +6,7 @@ defmodule Mobilizon.Service.Metadata.Instance do
|
|||||||
alias Phoenix.HTML
|
alias Phoenix.HTML
|
||||||
alias Phoenix.HTML.Tag
|
alias Phoenix.HTML.Tag
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
|
|
||||||
def build_tags() do
|
def build_tags() do
|
||||||
description = process_description(Config.instance_description())
|
description = process_description(Config.instance_description())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
defmodule MobilizonWeb.Auth.Context do
|
defmodule Mobilizon.Web.Auth.Context do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Guardian context for MobilizonWeb
|
Guardian context for Mobilizon.Web
|
||||||
"""
|
"""
|
||||||
@behaviour Plug
|
@behaviour Plug
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Auth.ErrorHandler do
|
defmodule Mobilizon.Web.Auth.ErrorHandler do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
In case we have an auth error
|
In case we have an auth error
|
||||||
"""
|
"""
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Auth.Guardian do
|
defmodule Mobilizon.Web.Auth.Guardian do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the JWT tokens encoding and decoding
|
Handles the JWT tokens encoding and decoding
|
||||||
"""
|
"""
|
@ -1,14 +1,14 @@
|
|||||||
defmodule MobilizonWeb.Auth.Pipeline do
|
defmodule Mobilizon.Web.Auth.Pipeline do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles the app sessions
|
Handles the app sessions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Guardian.Plug.Pipeline,
|
use Guardian.Plug.Pipeline,
|
||||||
otp_app: :mobilizon,
|
otp_app: :mobilizon,
|
||||||
module: MobilizonWeb.Auth.Guardian,
|
module: Mobilizon.Web.Auth.Guardian,
|
||||||
error_handler: MobilizonWeb.Auth.ErrorHandler
|
error_handler: Mobilizon.Web.Auth.ErrorHandler
|
||||||
|
|
||||||
plug(Guardian.Plug.VerifyHeader, realm: "Bearer")
|
plug(Guardian.Plug.VerifyHeader, realm: "Bearer")
|
||||||
plug(Guardian.Plug.LoadResource, allow_blank: true)
|
plug(Guardian.Plug.LoadResource, allow_blank: true)
|
||||||
plug(MobilizonWeb.Auth.Context)
|
plug(Mobilizon.Web.Auth.Context)
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Cache.ActivityPub do
|
defmodule Mobilizon.Web.Cache.ActivityPub do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
ActivityPub related cache.
|
ActivityPub related cache.
|
||||||
"""
|
"""
|
||||||
@ -9,8 +9,8 @@ defmodule MobilizonWeb.Cache.ActivityPub do
|
|||||||
|
|
||||||
alias Mobilizon.Federation.ActivityPub.Relay
|
alias Mobilizon.Federation.ActivityPub.Relay
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
@cache :activity_pub
|
@cache :activity_pub
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
defmodule MobilizonWeb.Cache do
|
defmodule Mobilizon.Web.Cache do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Facade module which provides access to all cached data.
|
Facade module which provides access to all cached data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
|
||||||
alias MobilizonWeb.Cache.ActivityPub
|
alias Mobilizon.Web.Cache.ActivityPub
|
||||||
|
|
||||||
@caches [:activity_pub, :feed, :ics]
|
@caches [:activity_pub, :feed, :ics]
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
defmodule MobilizonWeb.GraphQLSocket do
|
defmodule Mobilizon.Web.GraphQLSocket do
|
||||||
use Phoenix.Socket
|
use Phoenix.Socket
|
||||||
|
|
||||||
use Absinthe.Phoenix.Socket,
|
use Absinthe.Phoenix.Socket,
|
||||||
schema: MobilizonWeb.Schema
|
schema: Mobilizon.Web.Schema
|
||||||
|
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
def connect(%{"token" => token}, socket) do
|
def connect(%{"token" => token}, socket) do
|
||||||
with {:ok, authed_socket} <-
|
with {:ok, authed_socket} <-
|
||||||
Guardian.Phoenix.Socket.authenticate(socket, MobilizonWeb.Auth.Guardian, token),
|
Guardian.Phoenix.Socket.authenticate(socket, Mobilizon.Web.Auth.Guardian, token),
|
||||||
%User{} = user <- Guardian.Phoenix.Socket.current_resource(authed_socket) do
|
%User{} = user <- Guardian.Phoenix.Socket.current_resource(authed_socket) do
|
||||||
authed_socket =
|
authed_socket =
|
||||||
Absinthe.Phoenix.Socket.put_options(socket,
|
Absinthe.Phoenix.Socket.put_options(socket,
|
@ -3,8 +3,8 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/activity_pub_controller.ex
|
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/activity_pub/activity_pub_controller.ex
|
||||||
|
|
||||||
defmodule MobilizonWeb.ActivityPubController do
|
defmodule Mobilizon.Web.ActivityPubController do
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Config}
|
alias Mobilizon.{Actors, Config}
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
@ -12,14 +12,14 @@ defmodule MobilizonWeb.ActivityPubController do
|
|||||||
alias Mobilizon.Federation.ActivityPub
|
alias Mobilizon.Federation.ActivityPub
|
||||||
alias Mobilizon.Federation.ActivityPub.Federator
|
alias Mobilizon.Federation.ActivityPub.Federator
|
||||||
|
|
||||||
alias MobilizonWeb.ActivityPub.ActorView
|
alias Mobilizon.Web.ActivityPub.ActorView
|
||||||
alias MobilizonWeb.Cache
|
alias Mobilizon.Web.Cache
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
action_fallback(:errors)
|
action_fallback(:errors)
|
||||||
|
|
||||||
plug(MobilizonWeb.Plugs.Federating when action in [:inbox, :relay])
|
plug(Mobilizon.Web.Plugs.Federating when action in [:inbox, :relay])
|
||||||
plug(:relay_active? when action in [:relay])
|
plug(:relay_active? when action in [:relay])
|
||||||
|
|
||||||
def relay_active?(conn, _) do
|
def relay_active?(conn, _) do
|
@ -1,15 +1,15 @@
|
|||||||
defmodule MobilizonWeb.FallbackController do
|
defmodule Mobilizon.Web.FallbackController do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Translates controller action results into valid `Plug.Conn` responses.
|
Translates controller action results into valid `Plug.Conn` responses.
|
||||||
|
|
||||||
See `Phoenix.Controller.action_fallback/1` for more details.
|
See `Phoenix.Controller.action_fallback/1` for more details.
|
||||||
"""
|
"""
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
def call(conn, {:error, :not_found}) do
|
def call(conn, {:error, :not_found}) do
|
||||||
conn
|
conn
|
||||||
|> put_status(:not_found)
|
|> put_status(:not_found)
|
||||||
|> put_view(MobilizonWeb.ErrorView)
|
|> put_view(Mobilizon.Web.ErrorView)
|
||||||
|> render(:"404")
|
|> render(:"404")
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,10 +1,10 @@
|
|||||||
defmodule MobilizonWeb.FeedController do
|
defmodule Mobilizon.Web.FeedController do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Controller to serve RSS, ATOM and iCal Feeds
|
Controller to serve RSS, ATOM and iCal Feeds
|
||||||
"""
|
"""
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
plug(:put_layout, false)
|
plug(:put_layout, false)
|
||||||
action_fallback(MobilizonWeb.FallbackController)
|
action_fallback(Mobilizon.Web.FallbackController)
|
||||||
|
|
||||||
def actor(conn, %{"name" => name, "format" => "atom"}) do
|
def actor(conn, %{"name" => name, "format" => "atom"}) do
|
||||||
case Cachex.fetch(:feed, "actor_" <> name) do
|
case Cachex.fetch(:feed, "actor_" <> name) do
|
@ -3,15 +3,15 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/media_proxy/controller.ex
|
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/media_proxy/controller.ex
|
||||||
|
|
||||||
defmodule MobilizonWeb.MediaProxyController do
|
defmodule Mobilizon.Web.MediaProxyController do
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
alias Plug.Conn
|
alias Plug.Conn
|
||||||
|
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
|
|
||||||
alias MobilizonWeb.MediaProxy
|
alias Mobilizon.Web.MediaProxy
|
||||||
alias MobilizonWeb.ReverseProxy
|
alias Mobilizon.Web.ReverseProxy
|
||||||
|
|
||||||
@default_proxy_opts [max_body_length: 25 * 1_048_576, http: [follow_redirect: true]]
|
@default_proxy_opts [max_body_length: 25 * 1_048_576, http: [follow_redirect: true]]
|
||||||
|
|
@ -3,14 +3,14 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
|
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
|
||||||
|
|
||||||
defmodule MobilizonWeb.NodeInfoController do
|
defmodule Mobilizon.Web.NodeInfoController do
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
alias Mobilizon.Service.Statistics
|
alias Mobilizon.Service.Statistics
|
||||||
|
|
||||||
alias MobilizonWeb.Endpoint
|
alias Mobilizon.Web.Endpoint
|
||||||
alias MobilizonWeb.Router.Helpers, as: Routes
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
@node_info_supported_versions ["2.0", "2.1"]
|
@node_info_supported_versions ["2.0", "2.1"]
|
||||||
@node_info_schema_uri "http://nodeinfo.diaspora.software/ns/schema/"
|
@node_info_schema_uri "http://nodeinfo.diaspora.software/ns/schema/"
|
@ -1,13 +1,13 @@
|
|||||||
defmodule MobilizonWeb.PageController do
|
defmodule Mobilizon.Web.PageController do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Controller to load our webapp
|
Controller to load our webapp
|
||||||
"""
|
"""
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
alias MobilizonWeb.Cache
|
alias Mobilizon.Web.Cache
|
||||||
|
|
||||||
plug(:put_layout, false)
|
plug(:put_layout, false)
|
||||||
action_fallback(MobilizonWeb.FallbackController)
|
action_fallback(Mobilizon.Web.FallbackController)
|
||||||
|
|
||||||
def index(conn, _params), do: render(conn, :index)
|
def index(conn, _params), do: render(conn, :index)
|
||||||
|
|
@ -3,16 +3,16 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/web_finger/web_finger_controller.ex
|
# Upstream: https://git.pleroma.social/pleroma/pleroma/blob/develop/lib/pleroma/web/web_finger/web_finger_controller.ex
|
||||||
|
|
||||||
defmodule MobilizonWeb.WebFingerController do
|
defmodule Mobilizon.Web.WebFingerController do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles Webfinger requests
|
Handles Webfinger requests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use MobilizonWeb, :controller
|
use Mobilizon.Web, :controller
|
||||||
|
|
||||||
alias Mobilizon.Federation.WebFinger
|
alias Mobilizon.Federation.WebFinger
|
||||||
|
|
||||||
plug(MobilizonWeb.Plugs.Federating)
|
plug(Mobilizon.Web.Plugs.Federating)
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Provides /.well-known/host-meta
|
Provides /.well-known/host-meta
|
@ -1,23 +1,23 @@
|
|||||||
defmodule MobilizonWeb.Email.Admin do
|
defmodule Mobilizon.Web.Email.Admin do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles emails sent to admins.
|
Handles emails sent to admins.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||||
|
|
||||||
import Bamboo.Phoenix
|
import Bamboo.Phoenix
|
||||||
|
|
||||||
import MobilizonWeb.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
alias Mobilizon.Reports.Report
|
alias Mobilizon.Reports.Report
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
@spec report(User.t(), Report.t(), String.t()) :: Bamboo.Email.t()
|
@spec report(User.t(), Report.t(), String.t()) :: Bamboo.Email.t()
|
||||||
def report(%User{email: email}, %Report{} = report, locale \\ "en") do
|
def report(%User{email: email}, %Report{} = report, locale \\ "en") do
|
||||||
MobilizonWeb.Gettext.put_locale(locale)
|
Mobilizon.Web.Gettext.put_locale(locale)
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Email.Checker do
|
defmodule Mobilizon.Web.Email.Checker do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Provides a function to test emails against a "not so bad" regex.
|
Provides a function to test emails against a "not so bad" regex.
|
||||||
"""
|
"""
|
@ -1,9 +1,9 @@
|
|||||||
defmodule MobilizonWeb.Email do
|
defmodule Mobilizon.Web.Email do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
The Email context.
|
The Email context.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||||
|
|
||||||
alias Mobilizon.Config
|
alias Mobilizon.Config
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ defmodule MobilizonWeb.Email do
|
|||||||
|> from({Config.instance_name(), Config.instance_email_from()})
|
|> from({Config.instance_name(), Config.instance_email_from()})
|
||||||
|> put_header("Reply-To", Config.instance_email_reply_to())
|
|> put_header("Reply-To", Config.instance_email_reply_to())
|
||||||
|> assign(:instance, instance)
|
|> assign(:instance, instance)
|
||||||
|> put_html_layout({MobilizonWeb.EmailView, "email.html"})
|
|> put_html_layout({Mobilizon.Web.EmailView, "email.html"})
|
||||||
|> put_text_layout({MobilizonWeb.EmailView, "email.text"})
|
|> put_text_layout({Mobilizon.Web.EmailView, "email.text"})
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,13 +1,13 @@
|
|||||||
defmodule MobilizonWeb.Email.Event do
|
defmodule Mobilizon.Web.Email.Event do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles emails sent about events.
|
Handles emails sent about events.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||||
|
|
||||||
import Bamboo.Phoenix
|
import Bamboo.Phoenix
|
||||||
|
|
||||||
import MobilizonWeb.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.Events
|
alias Mobilizon.Events
|
||||||
@ -15,7 +15,7 @@ defmodule MobilizonWeb.Email.Event do
|
|||||||
alias Mobilizon.Storage.Repo
|
alias Mobilizon.Storage.Repo
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
alias MobilizonWeb.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
@important_changes [:title, :begins_on, :ends_on, :status]
|
@important_changes [:title, :begins_on, :ends_on, :status]
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ defmodule MobilizonWeb.Email.Event do
|
|||||||
changes,
|
changes,
|
||||||
locale \\ "en"
|
locale \\ "en"
|
||||||
) do
|
) do
|
||||||
MobilizonWeb.Gettext.put_locale(locale)
|
Mobilizon.Web.Gettext.put_locale(locale)
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
@ -1,4 +1,4 @@
|
|||||||
defmodule MobilizonWeb.Email.Mailer do
|
defmodule Mobilizon.Web.Email.Mailer do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Mobilizon Mailer.
|
Mobilizon Mailer.
|
||||||
"""
|
"""
|
@ -1,19 +1,19 @@
|
|||||||
defmodule MobilizonWeb.Email.Participation do
|
defmodule Mobilizon.Web.Email.Participation do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Handles emails sent about participation.
|
Handles emails sent about participation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Bamboo.Phoenix, view: MobilizonWeb.EmailView
|
use Bamboo.Phoenix, view: Mobilizon.Web.EmailView
|
||||||
|
|
||||||
import Bamboo.Phoenix
|
import Bamboo.Phoenix
|
||||||
|
|
||||||
import MobilizonWeb.Gettext
|
import Mobilizon.Web.Gettext
|
||||||
|
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.Events.Participant
|
alias Mobilizon.Events.Participant
|
||||||
|
|
||||||
alias MobilizonWeb.Email
|
alias Mobilizon.Web.Email
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Send emails to local user
|
Send emails to local user
|
||||||
@ -46,7 +46,7 @@ defmodule MobilizonWeb.Email.Participation do
|
|||||||
%Participant{event: event, role: :rejected},
|
%Participant{event: event, role: :rejected},
|
||||||
locale
|
locale
|
||||||
) do
|
) do
|
||||||
MobilizonWeb.Gettext.put_locale(locale)
|
Mobilizon.Web.Gettext.put_locale(locale)
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
||||||
@ -67,7 +67,7 @@ defmodule MobilizonWeb.Email.Participation do
|
|||||||
%Participant{event: event, role: :participant},
|
%Participant{event: event, role: :participant},
|
||||||
locale
|
locale
|
||||||
) do
|
) do
|
||||||
MobilizonWeb.Gettext.put_locale(locale)
|
Mobilizon.Web.Gettext.put_locale(locale)
|
||||||
|
|
||||||
subject =
|
subject =
|
||||||
gettext(
|
gettext(
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user