2019-11-21 15:51:13 +01:00
|
|
|
defmodule Mix.Tasks.Mobilizon.Actors.Show do
|
|
|
|
@moduledoc """
|
|
|
|
Task to display an actor details
|
|
|
|
"""
|
|
|
|
use Mix.Task
|
|
|
|
alias Mobilizon.Actors
|
|
|
|
alias Mobilizon.Actors.Actor
|
2020-10-30 15:16:01 +01:00
|
|
|
import Mix.Tasks.Mobilizon.Common
|
2019-11-21 15:51:13 +01:00
|
|
|
|
|
|
|
@shortdoc "Show a Mobilizon user details"
|
|
|
|
|
|
|
|
@impl Mix.Task
|
|
|
|
def run([preferred_username]) do
|
2020-10-30 15:16:01 +01:00
|
|
|
start_mobilizon()
|
2019-11-21 15:51:13 +01:00
|
|
|
|
|
|
|
case {:actor, Actors.get_actor_by_name_with_preload(preferred_username)} do
|
|
|
|
{:actor, %Actor{} = actor} ->
|
2020-10-30 15:16:01 +01:00
|
|
|
shell_info("""
|
2019-11-21 15:51:13 +01:00
|
|
|
Informations for the actor #{actor.preferred_username}:
|
|
|
|
- Type: #{actor.type}
|
|
|
|
- Domain: #{if is_nil(actor.domain), do: "Local", else: actor.domain}
|
|
|
|
- Name: #{actor.name}
|
|
|
|
- Summary: #{actor.summary}
|
|
|
|
- User: #{if is_nil(actor.user), do: "Remote", else: actor.user.email}
|
|
|
|
""")
|
|
|
|
|
|
|
|
{:actor, nil} ->
|
2020-10-30 15:16:01 +01:00
|
|
|
shell_error("Error: No such actor")
|
2019-11-21 15:51:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(_) do
|
2020-10-30 15:16:01 +01:00
|
|
|
shell_error("mobilizon.actors.show requires an username as argument")
|
2019-11-21 15:51:13 +01:00
|
|
|
end
|
|
|
|
end
|