@@ -21,10 +21,6 @@ defmodule MobilizonWeb.NodeInfoController do
|
||||
|
||||
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
|
||||
def nodeinfo(conn, %{"version" => "2.0"}) do
|
||||
import Logger
|
||||
Logger.debug(inspect(@instance))
|
||||
# stats = Stats.get_stats()
|
||||
|
||||
response = %{
|
||||
version: "2.0",
|
||||
software: %{
|
||||
@@ -39,12 +35,10 @@ defmodule MobilizonWeb.NodeInfoController do
|
||||
openRegistrations: Keyword.get(@instance, :registrations_open),
|
||||
usage: %{
|
||||
users: %{
|
||||
# total: stats.user_count || 0
|
||||
total: Actors.count_users()
|
||||
},
|
||||
localPosts: Events.count_local_events(),
|
||||
localComments: Events.count_local_comments()
|
||||
# localPosts: stats.status_count || 0
|
||||
},
|
||||
metadata: %{
|
||||
nodeName: Keyword.get(@instance, :name)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
defmodule MobilizonWeb.Resolvers.Actor do
|
||||
alias Mobilizon.Actors.Actor, as: ActorSchema
|
||||
alias Mobilizon.Actors.User
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Category do
|
||||
require Logger
|
||||
alias Mobilizon.Actors.User
|
||||
|
||||
def list_categories(_parent, _args, _resolution) do
|
||||
categories =
|
||||
@@ -13,7 +14,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{
|
||||
context: %{current_user: user}
|
||||
context: %{current_user: %User{} = _user}
|
||||
}) do
|
||||
with {:ok, category} <-
|
||||
Mobilizon.Events.create_category(%{
|
||||
@@ -35,7 +36,7 @@ defmodule MobilizonWeb.Resolvers.Category do
|
||||
end
|
||||
end
|
||||
|
||||
def create_category(_parent, %{title: title, picture: picture, description: description}, %{}) do
|
||||
def create_category(_parent, _args, %{}) do
|
||||
{:error, "You are not allowed to create a category if not connected"}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Event do
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Actors
|
||||
|
||||
def list_events(_parent, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_events()}
|
||||
@@ -15,10 +16,20 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participant for event (separate request)
|
||||
"""
|
||||
def list_participants_for_event(_parent, %{uuid: uuid}, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Search events by title
|
||||
"""
|
||||
@@ -30,7 +41,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
Search events and actors by title
|
||||
"""
|
||||
def search_events_and_actors(_parent, %{search: search, page: page, limit: limit}, _resolution) do
|
||||
search = String.strip(search)
|
||||
search = String.trim(search)
|
||||
|
||||
found =
|
||||
case String.contains?(search, "@") do
|
||||
@@ -52,14 +63,9 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
{:ok, found}
|
||||
end
|
||||
|
||||
@doc """
|
||||
List participants for event (through an event request)
|
||||
"""
|
||||
def list_participants_for_event(%{uuid: uuid}, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_participants_for_event(uuid)}
|
||||
end
|
||||
|
||||
def create_event(_parent, args, %{context: %{current_user: user}}) do
|
||||
organizer_actor_id = Map.get(args, "organizer_actor_id") || Actors.get_actor_for_user(user).id
|
||||
args = args |> Map.put("organizer_actor_id", organizer_actor_id)
|
||||
Mobilizon.Events.create_event(args)
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
{:error, "You need to be logged-in to view current user"}
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Login an user. Returns a token and the user
|
||||
"""
|
||||
def login_user(_parent, %{email: email, password: password}, _resolution) do
|
||||
@@ -37,7 +37,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc """
|
||||
@doc """
|
||||
Register an user :
|
||||
- create the user
|
||||
- create the actor
|
||||
@@ -111,7 +111,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||
end
|
||||
end
|
||||
|
||||
@desc "Change an user default actor"
|
||||
@doc "Change an user default actor"
|
||||
def change_default_actor(_parent, %{preferred_username: username}, %{
|
||||
context: %{current_user: user}
|
||||
}) do
|
||||
|
||||
@@ -10,9 +10,6 @@ defmodule MobilizonWeb.Schema do
|
||||
import_types(Absinthe.Type.Custom)
|
||||
import_types(Absinthe.Plug.Types)
|
||||
|
||||
# import_types(MobilizonWeb.Schema.EventTypes)
|
||||
# import_types(MobilizonWeb.Schema.ActorTypes)
|
||||
|
||||
alias MobilizonWeb.Resolvers
|
||||
|
||||
@desc "An ActivityPub actor"
|
||||
|
||||
@@ -23,7 +23,7 @@ defmodule MobilizonWeb.Uploaders.Category do
|
||||
end
|
||||
|
||||
# Override the persisted filenames:
|
||||
def filename(version, {file, %{title: title}}) do
|
||||
def filename(version, {_file, %{title: title}}) do
|
||||
"#{title}_#{version}"
|
||||
end
|
||||
|
||||
|
||||
@@ -3,14 +3,10 @@ defmodule MobilizonWeb.ActivityPub.ActorView do
|
||||
|
||||
alias MobilizonWeb.ActivityPub.ActorView
|
||||
alias MobilizonWeb.ActivityPub.ObjectView
|
||||
alias MobilizonWeb.WebFinger
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Repo
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Activity
|
||||
import Ecto.Query
|
||||
|
||||
def render("actor.json", %{actor: actor}) do
|
||||
public_key = Mobilizon.Service.ActivityPub.Utils.pem_to_public_key_pem(actor.keys)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
defmodule MobilizonWeb.ActivityPub.ObjectView do
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.ActivityPub.ObjectView
|
||||
alias Mobilizon.Service.ActivityPub.Transmogrifier
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
|
||||
def render("event.json", %{event: event}) do
|
||||
@@ -37,14 +36,14 @@ defmodule MobilizonWeb.ActivityPub.ObjectView do
|
||||
Map.merge(comment, Utils.make_json_ld_header())
|
||||
end
|
||||
|
||||
def render("category.json", %{category: category}) do
|
||||
def render("category.json", %{category: category}) when not is_nil(category) do
|
||||
%{
|
||||
"identifier" => category.id,
|
||||
"name" => category.title
|
||||
}
|
||||
end
|
||||
|
||||
def render("category.json", %{category: nil}) do
|
||||
def render("category.json", %{category: _category}) do
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user