aboutsummaryrefslogtreecommitdiff
path: root/lib/mix
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2020-05-28 12:07:30 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2020-05-28 12:23:19 +0300
commitfddba6739de7e5f07f14338ccf5310a143a498cd (patch)
tree7c6b297ef53d5176059597ff4589bbbcce4afff2 /lib/mix
parent6cab0f820ec2ee112eb4dec84fa7d1c9cd9fca73 (diff)
parenta23df89b5d457ef56154069c132c75a590de810f (diff)
downloadpleroma-fddba6739de7e5f07f14338ccf5310a143a498cd.tar.gz
Merge develop
Diffstat (limited to 'lib/mix')
-rw-r--r--lib/mix/tasks/pleroma/benchmark.ex3
-rw-r--r--lib/mix/tasks/pleroma/digest.ex7
-rw-r--r--lib/mix/tasks/pleroma/instance.ex8
-rw-r--r--lib/mix/tasks/pleroma/user.ex27
4 files changed, 18 insertions, 27 deletions
diff --git a/lib/mix/tasks/pleroma/benchmark.ex b/lib/mix/tasks/pleroma/benchmark.ex
index 6ab7fe8ef..dd2b9c8f2 100644
--- a/lib/mix/tasks/pleroma/benchmark.ex
+++ b/lib/mix/tasks/pleroma/benchmark.ex
@@ -67,8 +67,7 @@ defmodule Mix.Tasks.Pleroma.Benchmark do
Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
activities: activities,
for: user,
- as: :activity,
- skip_relationships: true
+ as: :activity
})
end
},
diff --git a/lib/mix/tasks/pleroma/digest.ex b/lib/mix/tasks/pleroma/digest.ex
index 7d09e70c5..3595f912d 100644
--- a/lib/mix/tasks/pleroma/digest.ex
+++ b/lib/mix/tasks/pleroma/digest.ex
@@ -1,5 +1,6 @@
defmodule Mix.Tasks.Pleroma.Digest do
use Mix.Task
+ import Mix.Pleroma
@shortdoc "Manages digest emails"
@moduledoc File.read!("docs/administration/CLI_tasks/digest.md")
@@ -22,12 +23,10 @@ defmodule Mix.Tasks.Pleroma.Digest do
with %Swoosh.Email{} = email <- Pleroma.Emails.UserEmail.digest_email(patched_user) do
{:ok, _} = Pleroma.Emails.Mailer.deliver(email)
- Mix.shell().info("Digest email have been sent to #{nickname} (#{user.email})")
+ shell_info("Digest email have been sent to #{nickname} (#{user.email})")
else
_ ->
- Mix.shell().info(
- "Cound't find any mentions for #{nickname} since #{last_digest_emailed_at}"
- )
+ shell_info("Cound't find any mentions for #{nickname} since #{last_digest_emailed_at}")
end
end
end
diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex
index 3e0f0fdc8..e1eb57061 100644
--- a/lib/mix/tasks/pleroma/instance.ex
+++ b/lib/mix/tasks/pleroma/instance.ex
@@ -154,6 +154,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
"What directory should media uploads go in (when using the local uploader)?",
Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads])
)
+ |> Path.expand()
static_dir =
get_option(
@@ -162,6 +163,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
"What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)?",
Pleroma.Config.get([:instance, :static_dir])
)
+ |> Path.expand()
Config.put([:instance, :static_dir], static_dir)
@@ -271,7 +273,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
shell_info("Writing the postgres script to #{psql_path}.")
File.write(psql_path, result_psql)
- write_robots_txt(indexable, template_dir)
+ write_robots_txt(static_dir, indexable, template_dir)
shell_info(
"\n All files successfully written! Refer to the installation instructions for your platform for next steps."
@@ -291,15 +293,13 @@ defmodule Mix.Tasks.Pleroma.Instance do
end
end
- defp write_robots_txt(indexable, template_dir) do
+ defp write_robots_txt(static_dir, indexable, template_dir) do
robots_txt =
EEx.eval_file(
template_dir <> "/robots_txt.eex",
indexable: indexable
)
- static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/")
-
unless File.exists?(static_dir) do
File.mkdir_p!(static_dir)
end
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index f15112e9e..ce2f83665 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -8,6 +8,8 @@ defmodule Mix.Tasks.Pleroma.User do
alias Ecto.Changeset
alias Pleroma.User
alias Pleroma.UserInviteToken
+ alias Pleroma.Web.ActivityPub.Builder
+ alias Pleroma.Web.ActivityPub.Pipeline
@shortdoc "Manages Pleroma users"
@moduledoc File.read!("docs/administration/CLI_tasks/user.md")
@@ -96,8 +98,9 @@ defmodule Mix.Tasks.Pleroma.User do
def run(["rm", nickname]) do
start_pleroma()
- with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
- User.perform(:delete, user)
+ with %User{local: true} = user <- User.get_cached_by_nickname(nickname),
+ {:ok, delete_data, _} <- Builder.delete(user, user.ap_id),
+ {:ok, _delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
shell_info("User #{nickname} deleted.")
else
_ -> shell_error("No local user #{nickname}")
@@ -141,28 +144,18 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
- def run(["unsubscribe", nickname]) do
+ def run(["deactivate", nickname]) do
start_pleroma()
with %User{} = user <- User.get_cached_by_nickname(nickname) do
shell_info("Deactivating #{user.nickname}")
User.deactivate(user)
-
- user
- |> User.get_friends()
- |> Enum.each(fn friend ->
- user = User.get_cached_by_id(user.id)
-
- shell_info("Unsubscribing #{friend.nickname} from #{user.nickname}")
- User.unfollow(user, friend)
- end)
-
:timer.sleep(500)
user = User.get_cached_by_id(user.id)
- if Enum.empty?(User.get_friends(user)) do
- shell_info("Successfully unsubscribed all followers from #{user.nickname}")
+ if Enum.empty?(Enum.filter(User.get_friends(user), & &1.local)) do
+ shell_info("Successfully unsubscribed all local followers from #{user.nickname}")
end
else
_ ->
@@ -170,7 +163,7 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
- def run(["unsubscribe_all_from_instance", instance]) do
+ def run(["deactivate_all_from_instance", instance]) do
start_pleroma()
Pleroma.User.Query.build(%{nickname: "@#{instance}"})
@@ -178,7 +171,7 @@ defmodule Mix.Tasks.Pleroma.User do
|> Stream.each(fn users ->
users
|> Enum.each(fn user ->
- run(["unsubscribe", user.nickname])
+ run(["deactivate", user.nickname])
end)
end)
|> Stream.run()