Merge branch 'develop' into issue/1383
authorMaksim Pechnikov <parallel588@gmail.com>
Mon, 10 Feb 2020 17:49:20 +0000 (20:49 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Mon, 10 Feb 2020 17:49:20 +0000 (20:49 +0300)
1  2 
config/config.exs
config/description.exs
docs/configuration/cheatsheet.md
mix.exs
mix.lock

diff --combined config/config.exs
index 98a44efb0c569fcddfd6ddb87ac1cb170eb4f182,34716cf37fd32268cb83055b4714be0ce5a1f732..41c1ff6371a21e56af6a4fdaf45aaf79801096c1
@@@ -51,6 -51,20 +51,6 @@@ config :pleroma, Pleroma.Repo
    telemetry_event: [Pleroma.Repo.Instrumenter],
    migration_lock: nil
  
 -scheduled_jobs =
 -  with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest],
 -       true <- digest_config[:active] do
 -    [{digest_config[:schedule], {Pleroma.Daemons.DigestEmailDaemon, :perform, []}}]
 -  else
 -    _ -> []
 -  end
 -
 -config :pleroma, Pleroma.Scheduler,
 -  global: true,
 -  overlap: true,
 -  timezone: :utc,
 -  jobs: scheduled_jobs
 -
  config :pleroma, Pleroma.Captcha,
    enabled: true,
    seconds_valid: 300,
@@@ -257,7 -271,8 +257,8 @@@ config :pleroma, :instance
    account_field_name_length: 512,
    account_field_value_length: 2048,
    external_user_synchronization: true,
-   extended_nickname_format: true
+   extended_nickname_format: true,
+   cleanup_attachments: false
  
  config :pleroma, :feed,
    post_title: %{
@@@ -480,12 -495,6 +481,12 @@@ config :pleroma, Oban
      scheduled_activities: 10,
      background: 5,
      attachments_cleanup: 5
 +  ],
 +  crontab: [
 +    {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
 +    {"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
 +    {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
 +    {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}
    ]
  
  config :pleroma, :workers,
@@@ -500,7 -509,6 +501,6 @@@ config :pleroma, :fetch_initial_posts
  
  config :auto_linker,
    opts: [
-     scheme: true,
      extra: true,
      # TODO: Set to :no_scheme when it works properly
      validate_tld: true,
@@@ -570,6 -578,7 +570,6 @@@ config :pleroma, Pleroma.ScheduledActiv
  config :pleroma, :email_notifications,
    digest: %{
      active: false,
 -    schedule: "0 0 * * 0",
      interval: 7,
      inactivity_threshold: 7
    }
  config :pleroma, :oauth2,
    token_expires_in: 600,
    issue_new_refresh_token: true,
 -  clean_expired_tokens: false,
 -  clean_expired_tokens_interval: 86_400_000
 +  clean_expired_tokens: false
  
  config :pleroma, :database, rum_enabled: false
  
@@@ -612,6 -622,7 +612,6 @@@ config :pleroma, :modules, runtime_dir
  
  config :pleroma, configurable_from_database: false
  
 -config :swarm, node_blacklist: [~r/myhtml_.*$/]
  # Import environment specific config. This must remain at the bottom
  # of this file so it overrides the configuration defined above.
  import_config "#{Mix.env()}.exs"
diff --combined config/description.exs
index 434fc2ef1682a5e2e0d549885e7fe78c9f9353ac,6b912a07e3e190ebed40b1567f53d7fa705d104e..e5bac9b3fa4f229ef5c2d62118509fd6d9c2c8a2
@@@ -764,6 -764,15 +764,15 @@@ config :pleroma, :config_description, 
            "Set to `true` to use extended local nicknames format (allows underscores/dashes)." <>
              " This will break federation with older software for theses nicknames."
        },
+       %{
+         key: :cleanup_attachments,
+         type: :boolean,
+         description: """
+         "Set to `true` to remove associated attachments when status is removed.
+         This will not affect duplicates and attachments without status.
+         Enabling this will increase load to database when deleting statuses on larger instances.
+         """
+       },
        %{
          key: :max_pinned_statuses,
          type: :integer,
        },
        %{
          key: :limit_to_local_content,
-         type: [:atom, false],
+         type: {:dropdown, :atom},
          description:
            "Limit unauthenticated users to search for local statutes and users only. Default: `:unauthenticated`.",
          suggestions: [
      children: [
        %{
          key: :level,
-         type: :atom,
+         type: {:dropdown, :atom},
          description: "Log level",
          suggestions: [:debug, :info, :warn, :error]
        },
      children: [
        %{
          key: :level,
-         type: :atom,
+         type: {:dropdown, :atom},
          description: "Log level",
          suggestions: [:debug, :info, :warn, :error]
        },
      children: [
        %{
          key: :level,
-         type: :atom,
+         type: {:dropdown, :atom},
          description: "Log level",
          suggestions: [:debug, :info, :warn, :error]
        },
        },
        %{
          key: :verbose,
-         type: [:atom, false],
+         type: {:dropdown, :atom},
          description: "Logs verbose mode",
          suggestions: [false, :error, :warn, :info, :debug]
        },
        %{
          key: :new_window,
          type: :boolean,
-         description: "Set to `false` to remove target='_blank' attribute"
-       },
-       %{
-         key: :scheme,
-         type: :boolean,
-         description: "Set to `true` to link urls with schema http://google.com"
+         description: "Link urls will open in new window/tab"
        },
        %{
          key: :truncate,
          key: :clean_expired_tokens,
          type: :boolean,
          description: "Enable a background job to clean expired oauth tokens. Default: `false`."
 -      },
 -      %{
 -        key: :clean_expired_tokens_interval,
 -        type: :integer,
 -        description:
 -          "Interval to run the job to clean expired tokens. Default: 86_400_000 (24 hours).",
 -        suggestions: [86_400_000]
        }
      ]
    },
index 8af3394bb3e3840ee1631651a23b812050b9b3f6,f30aedc01ee832c7a79236f9ce644381b363661b..2bd9359832254b662c78224e81b1b78bdc393ba0
@@@ -69,6 -69,7 +69,7 @@@ You shouldn't edit the base config dire
  * `account_field_name_length`: An account field name maximum length (default: `512`).
  * `account_field_value_length`: An account field value maximum length (default: `2048`).
  * `external_user_synchronization`: Enabling following/followers counters synchronization for external users.
+ * `cleanup_attachments`: Remove attachments along with statuses. Does not affect duplicate files and attachments without status. Enabling this will increase load to database when deleting statuses on larger instances.
  
  ## Federation
  ### MRF policies
@@@ -512,7 -513,6 +513,7 @@@ Configuration options described in [Oba
  * `verbose` - logs verbosity
  * `prune` - non-retryable jobs [pruning settings](https://github.com/sorentwo/oban#pruning) (`:disabled` / `{:maxlen, value}` / `{:maxage, value}`)
  * `queues` - job queues (see below)
 +* `crontab` - periodic jobs, see [`Oban.Cron`](#obancron)
  
  Pleroma has the following queues:
  
  * `web_push` - Web push notifications
  * `scheduled_activities` - Scheduled activities, see [`Pleroma.ScheduledActivity`](#pleromascheduledactivity)
  
 +#### Oban.Cron
 +
 +Pleroma has these periodic job workers:
 +
 +`Pleroma.Workers.Cron.ClearOauthTokenWorker` - a job worker to cleanup expired oauth tokens.
 +
  Example:
  
  ```elixir
@@@ -540,9 -534,6 +541,9 @@@ config :pleroma, Oban
    queues: [
      federator_incoming: 50,
      federator_outgoing: 50
 +  ],
 +  crontab: [
 +    {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}
    ]
  ```
  
@@@ -825,7 -816,8 +826,7 @@@ Configure OAuth 2 provider capabilities
  
  * `token_expires_in` - The lifetime in seconds of the access token.
  * `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token.
 -* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`.
 -* `clean_expired_tokens_interval` - Interval to run the job to clean expired tokens. Defaults to `86_400_000` (24 hours).
 +* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. Interval settings sets in configuration periodic jobs [`Oban.Cron`](#obancron)
  
  ## Link parsing
  
@@@ -864,4 -856,5 +865,5 @@@ config :auto_linker
  
  
  ## :configurable_from_database
- Enable/disable configuration from database.
+ Boolean, enables/disables in-database configuration. Read [Transfering the config to/from the database](../administration/CLI_tasks/config.md) for more information.
diff --combined mix.exs
index 8f8616f18338a01a730626b43a36b60cb8f8cfae,f6794f12671d38b85e98b5c1c06b5ddb3a08870a..3e3eac521f8ff606c2b76a3b67cda36845b0801c
+++ b/mix.exs
@@@ -8,7 -8,7 +8,7 @@@ defmodule Pleroma.Mixfile d
        elixir: "~> 1.8",
        elixirc_paths: elixirc_paths(Mix.env()),
        compilers: [:phoenix, :gettext] ++ Mix.compilers(),
-       elixirc_options: [warnings_as_errors: true],
+       elixirc_options: [warnings_as_errors: warnings_as_errors(Mix.env())],
        xref: [exclude: [:eldap]],
        start_permanent: Mix.env() == :prod,
        aliases: aliases(),
@@@ -63,7 -63,7 +63,7 @@@
    def application do
      [
        mod: {Pleroma.Application, []},
 -      extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :fast_sanitize, :swarm],
 +      extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :fast_sanitize],
        included_applications: [:ex_syslogger]
      ]
    end
    defp elixirc_paths(:test), do: ["lib", "test/support"]
    defp elixirc_paths(_), do: ["lib"]
  
+   defp warnings_as_errors(:prod), do: false
+   # Uncomment this if you need testing configurable_from_database logic
+   # defp warnings_as_errors(:dev), do: false
+   defp warnings_as_errors(_), do: true
    # Specifies OAuth dependencies.
    defp oauth_deps do
      oauth_strategy_packages =
        {:ecto_enum, "~> 1.4"},
        {:ecto_sql, "~> 3.3.2"},
        {:postgrex, ">= 0.13.5"},
 -      {:oban, "~> 0.12.0"},
 -      {:quantum, "~> 2.3"},
 +      {:oban, "~> 0.12.1"},
        {:gettext, "~> 0.15"},
        {:comeonin, "~> 4.1.1"},
        {:pbkdf2_elixir, "~> 0.12.3"},
        {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)},
        {:ex_const, "~> 0.2"},
        {:plug_static_index_html, "~> 1.0.0"},
 -      {:excoveralls, "~> 0.11.1", only: :test},
 +      {:excoveralls, "~> 0.12.1", only: :test},
        {:flake_id, "~> 0.1.0"},
        {:remote_ip,
         git: "https://git.pleroma.social/pleroma/remote_ip.git",
        {:captcha,
         git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
         ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
-       {:mox, "~> 0.5", only: :test}
+       {:mox, "~> 0.5", only: :test},
+       {:restarter, path: "./restarter"}
      ] ++ oauth_deps()
    end
  
diff --combined mix.lock
index 1fe3085ee04717df96a1b3fd9750fa859705a189,b8a35a795a037e54de34e289dd17499b92558306..69eec54314d3dfe00ba014dee557c80f16ec897a
+++ b/mix.lock
@@@ -36,9 -36,9 +36,9 @@@
    "ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
    "ex_machina": {:hex, :ex_machina, "2.3.0", "92a5ad0a8b10ea6314b876a99c8c9e3f25f4dde71a2a835845b136b9adaf199a", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm"},
    "ex_syslogger": {:git, "https://github.com/slashmili/ex_syslogger.git", "f3963399047af17e038897c69e20d552e6899e1d", [tag: "1.4.0"]},
 -  "excoveralls": {:hex, :excoveralls, "0.11.2", "0c6f2c8db7683b0caa9d490fb8125709c54580b4255ffa7ad35f3264b075a643", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
 -  "fast_html": {:hex, :fast_html, "1.0.1", "5bc7df4dc4607ec2c314c16414e4111d79a209956c4f5df96602d194c61197f9", [:make, :mix], [], "hexpm"},
 -  "fast_sanitize": {:hex, :fast_sanitize, "0.1.6", "60a5ae96879956dea409a91a77f5dd2994c24cc10f80eefd8f9892ee4c0c7b25", [:mix], [{:fast_html, "~> 1.0", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
 +  "excoveralls": {:hex, :excoveralls, "0.12.1", "a553c59f6850d0aff3770e4729515762ba7c8e41eedde03208182a8dc9d0ce07", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
 +  "fast_html": {:hex, :fast_html, "0.99.4", "d80812664f0429607e1d880fba0ef04da87a2e4fa596701bcaae17953535695c", [:make, :mix], [], "hexpm"},
 +  "fast_sanitize": {:hex, :fast_sanitize, "0.1.4", "6c2e7203ca2f8275527a3021ba6e9d5d4ee213a47dc214a97c128737c9e56df1", [:mix], [{:fast_html, "~> 0.99", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
    "flake_id": {:hex, :flake_id, "0.1.0", "7716b086d2e405d09b647121a166498a0d93d1a623bead243e1f74216079ccb3", [:mix], [{:base62, "~> 1.2", [hex: :base62, repo: "hexpm", optional: false]}, {:ecto, ">= 2.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
    "floki": {:hex, :floki, "0.23.1", "e100306ce7d8841d70a559748e5091542e2cfc67ffb3ade92b89a8435034dab1", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm"},
    "gen_smtp": {:hex, :gen_smtp, "0.15.0", "9f51960c17769b26833b50df0b96123605a8024738b62db747fece14eb2fbfcc", [:rebar3], [], "hexpm"},
@@@ -77,7 -77,7 +77,7 @@@
    "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
    "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"},
    "phoenix_swoosh": {:hex, :phoenix_swoosh, "0.2.0", "a7e0b32077cd6d2323ae15198839b05d9caddfa20663fd85787479e81f89520e", [:mix], [{:phoenix, "~> 1.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.2", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:swoosh, "~> 0.1", [hex: :swoosh, repo: "hexpm", optional: false]}], "hexpm"},
-   "plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"},
+   "plug": {:hex, :plug, "1.9.0", "8d7c4e26962283ff9f8f3347bd73838e2413fbc38b7bb5467d5924f68f3a5a4a", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"},
    "plug_cowboy": {:hex, :plug_cowboy, "2.1.0", "b75768153c3a8a9e8039d4b25bb9b14efbc58e9c4a6e6a270abff1cd30cbe320", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
    "plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
    "plug_static_index_html": {:hex, :plug_static_index_html, "1.0.0", "840123d4d3975585133485ea86af73cb2600afd7f2a976f9f5fd8b3808e636a0", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
    "prometheus_phoenix": {:hex, :prometheus_phoenix, "1.3.0", "c4b527e0b3a9ef1af26bdcfbfad3998f37795b9185d475ca610fe4388fdd3bb5", [:mix], [{:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.3 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm"},
    "prometheus_plugs": {:hex, :prometheus_plugs, "1.1.5", "25933d48f8af3a5941dd7b621c889749894d8a1082a6ff7c67cc99dec26377c5", [:mix], [{:accept, "~> 0.1", [hex: :accept, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}, {:prometheus_process_collector, "~> 1.1", [hex: :prometheus_process_collector, repo: "hexpm", optional: true]}], "hexpm"},
    "quack": {:hex, :quack, "0.1.1", "cca7b4da1a233757fdb44b3334fce80c94785b3ad5a602053b7a002b5a8967bf", [:mix], [{:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: false]}, {:tesla, "~> 1.2.0", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm"},
 -  "quantum": {:hex, :quantum, "2.3.4", "72a0e8855e2adc101459eac8454787cb74ab4169de6ca50f670e72142d4960e9", [:mix], [{:calendar, "~> 0.17", [hex: :calendar, repo: "hexpm", optional: true]}, {:crontab, "~> 1.1", [hex: :crontab, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.12", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:swarm, "~> 3.3", [hex: :swarm, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: true]}], "hexpm"},
    "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
    "recon": {:git, "https://github.com/ferd/recon.git", "75d70c7c08926d2f24f1ee6de14ee50fe8a52763", [tag: "2.4.0"]},
    "remote_ip": {:git, "https://git.pleroma.social/pleroma/remote_ip.git", "825dc00aaba5a1b7c4202a532b696b595dd3bcb3", [ref: "825dc00aaba5a1b7c4202a532b696b595dd3bcb3"]},
    "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"},
 -  "swarm": {:hex, :swarm, "3.4.0", "64f8b30055d74640d2186c66354b33b999438692a91be275bb89cdc7e401f448", [:mix], [{:gen_state_machine, "~> 2.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:libring, "~> 1.0", [hex: :libring, repo: "hexpm", optional: false]}], "hexpm"},
    "sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm"},
    "swoosh": {:hex, :swoosh, "0.23.5", "bfd9404bbf5069b1be2ffd317923ce57e58b332e25dbca2a35dedd7820dfee5a", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
    "syslog": {:git, "https://github.com/Vagabond/erlang-syslog.git", "4a6c6f2c996483e86c1320e9553f91d337bcb6aa", [tag: "1.0.5"]},