diff options
| author | Ivan Tashkinov <ivant.business@gmail.com> | 2019-04-04 23:43:08 +0300 | 
|---|---|---|
| committer | Ivan Tashkinov <ivant.business@gmail.com> | 2019-04-04 23:43:08 +0300 | 
| commit | 45765918c377c6daf8ee8e5bfad4ea24f67766b6 (patch) | |
| tree | a8ccea9436d7c533a481939a4724c62d8ffac4c0 /lib/mix/tasks | |
| parent | f7cd9131d4aa0da3c4c0174acc56ce1bbdbd284c (diff) | |
| parent | 9c9eec62c2fb67507708dd9e5d3f80a098881a6e (diff) | |
| download | pleroma-45765918c377c6daf8ee8e5bfad4ea24f67766b6.tar.gz pleroma-45765918c377c6daf8ee8e5bfad4ea24f67766b6.zip | |
[#923] Merge remote-tracking branch 'remotes/upstream/develop' into twitter_oauth
# Conflicts:
#	mix.exs
Diffstat (limited to 'lib/mix/tasks')
| -rw-r--r-- | lib/mix/tasks/pleroma/instance.ex | 34 | ||||
| -rw-r--r-- | lib/mix/tasks/pleroma/robots_txt.eex | 2 | ||||
| -rw-r--r-- | lib/mix/tasks/pleroma/user.ex | 16 | 
3 files changed, 52 insertions, 0 deletions
| diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index 1ba452275..8f8d86a11 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -81,6 +81,14 @@ defmodule Mix.Tasks.Pleroma.Instance do        email = Common.get_option(options, :admin_email, "What is your admin email address?") +      indexable = +        Common.get_option( +          options, +          :indexable, +          "Do you want search engines to index your site? (y/n)", +          "y" +        ) === "y" +        dbhost =          Common.get_option(options, :dbhost, "What is the hostname of your database?", "localhost") @@ -142,6 +150,8 @@ defmodule Mix.Tasks.Pleroma.Instance do        Mix.shell().info("Writing #{psql_path}.")        File.write(psql_path, result_psql) +      write_robots_txt(indexable) +        Mix.shell().info(          "\n" <>            """ @@ -163,4 +173,28 @@ defmodule Mix.Tasks.Pleroma.Instance do        )      end    end + +  defp write_robots_txt(indexable) do +    robots_txt = +      EEx.eval_file( +        Path.expand("robots_txt.eex", __DIR__), +        indexable: indexable +      ) + +    static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/") + +    unless File.exists?(static_dir) do +      File.mkdir_p!(static_dir) +    end + +    robots_txt_path = Path.join(static_dir, "robots.txt") + +    if File.exists?(robots_txt_path) do +      File.cp!(robots_txt_path, "#{robots_txt_path}.bak") +      Mix.shell().info("Backing up existing robots.txt to #{robots_txt_path}.bak") +    end + +    File.write(robots_txt_path, robots_txt) +    Mix.shell().info("Writing #{robots_txt_path}.") +  end  end diff --git a/lib/mix/tasks/pleroma/robots_txt.eex b/lib/mix/tasks/pleroma/robots_txt.eex new file mode 100644 index 000000000..1af3c47ee --- /dev/null +++ b/lib/mix/tasks/pleroma/robots_txt.eex @@ -0,0 +1,2 @@ +User-Agent: * +Disallow: <%= if indexable, do: "", else: "/" %> diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 2487b4ab5..0d0bea8c0 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -32,6 +32,10 @@ defmodule Mix.Tasks.Pleroma.User do        mix pleroma.user rm NICKNAME +  ## Delete the user's activities. + +      mix pleroma.user delete_activities NICKNAME +    ## Deactivate or activate the user's account.        mix pleroma.user toggle_activated NICKNAME @@ -303,6 +307,18 @@ defmodule Mix.Tasks.Pleroma.User do      end    end +  def run(["delete_activities", nickname]) do +    Common.start_pleroma() + +    with %User{local: true} = user <- User.get_by_nickname(nickname) do +      User.delete_user_activities(user) +      Mix.shell().info("User #{nickname} statuses deleted.") +    else +      _ -> +        Mix.shell().error("No local user #{nickname}") +    end +  end +    defp set_moderator(user, value) do      info_cng = User.Info.admin_api_update(user.info, %{is_moderator: value}) | 
