diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f7a9f44c..59f7dfcdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Unreleased] +## [2.0.0] - 2019-03-08 ### Security - Mastodon API: Fix being able to request enourmous amount of statuses in timelines leading to DoS. Now limited to 40 per request. @@ -150,6 +150,43 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: Marking a conversation as read (`POST /api/v1/conversations/:id/read`) now no longer brings it to the top in the user's direct conversation list +## [1.1.9] - 2020-02-10 +### Fixed +- OTP: Inability to set the upload limit (again) +- Not being able to pin polls +- Streaming API: incorrect handling of reblog mutes +- Rejecting the user when field length limit is exceeded +- OpenGraph provider: html entities in descriptions + +## [1.1.8] - 2020-01-10 +### Fixed +- Captcha generation issues +- Returned Kocaptcha endpoint to configuration +- Captcha validity is now 5 minutes + +## [1.1.7] - 2019-12-13 +### Fixed +- OTP: Inability to set the upload limit +- OTP: Inability to override node name/distribution type to run 2 Pleroma instances on the same machine + +### Added +- Integrated captcha provider + +### Changed +- Captcha enabled by default +- Default Captcha provider changed from `Pleroma.Captcha.Kocaptcha` to `Pleroma.Captcha.Native` +- Better `Cache-Control` header for static content + +### Bundled Pleroma-FE Changes +#### Added +- Icons in the navigation panel + +#### Fixed +- Improved support unauthenticated view of private instances + +#### Removed +- Whitespace hack on empty post content + ## [1.1.6] - 2019-11-19 ### Fixed - Not being able to log into to third party apps when the browser is logged into mastofe diff --git a/docs/administration/backup.md b/docs/administration/backup.md index 692aa7368..be57bf74a 100644 --- a/docs/administration/backup.md +++ b/docs/administration/backup.md @@ -18,9 +18,8 @@ 6. Run `sudo -Hu postgres pg_restore -d -v -1 ` 7. If you installed a newer Pleroma version, you should run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any. 8. Restart the Pleroma service. -9. After you've restarted Pleroma, you will notice that postgres will take up more cpu resources than usual. A lot in fact. To fix this you must do a VACUUM ANLAYZE. This can also be done while the instance is still running like so: - $ sudo -u postgres psql pleroma_database_name - pleroma=# VACUUM ANALYZE; +9. Run `sudo -Hu postgres vacuumdb --all --analyze-in-stages`. This will quickly generate the statistics so that postgres can properly plan queries. + [^1]: Prefix with `MIX_ENV=prod` to run it using the production config file. ## Remove diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index 90f8c8008..3ad6edbfb 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -12,6 +12,19 @@ def start_pleroma do end {:ok, _} = Application.ensure_all_started(:pleroma) + + if Pleroma.Config.get(:env) not in [:test, :benchmark] do + pleroma_rebooted?() + end + end + + defp pleroma_rebooted? do + if Restarter.Pleroma.rebooted?() do + :ok + else + Process.sleep(10) + pleroma_rebooted?() + end end def load_pleroma do diff --git a/lib/pleroma/config/transfer_task.ex b/lib/pleroma/config/transfer_task.ex index 1846aa22c..435fc7450 100644 --- a/lib/pleroma/config/transfer_task.ex +++ b/lib/pleroma/config/transfer_task.ex @@ -42,7 +42,8 @@ def start_link(_) do @spec load_and_update_env([ConfigDB.t()]) :: :ok | false def load_and_update_env(deleted \\ [], restart_pleroma? \\ true) do - with true <- Pleroma.Config.get(:configurable_from_database), + with {:configurable, true} <- + {:configurable, Pleroma.Config.get(:configurable_from_database)}, true <- Ecto.Adapters.SQL.table_exists?(Repo, "config"), started_applications <- Application.started_applications() do # We need to restart applications for loaded settings take effect @@ -65,12 +66,15 @@ def load_and_update_env(deleted \\ [], restart_pleroma? \\ true) do if :pleroma in applications do List.delete(applications, :pleroma) ++ [:pleroma] else + Restarter.Pleroma.rebooted() applications end Enum.each(applications, &restart(started_applications, &1, Pleroma.Config.get(:env))) :ok + else + {:configurable, false} -> Restarter.Pleroma.rebooted() end end diff --git a/lib/pleroma/moderation_log.ex b/lib/pleroma/moderation_log.ex index c81477f48..e32895f70 100644 --- a/lib/pleroma/moderation_log.ex +++ b/lib/pleroma/moderation_log.ex @@ -387,24 +387,6 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} created users: #{users_to_nicknames_string(subjects)}" end - @spec get_log_entry_message(ModerationLog) :: String.t() - def get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "activate", - "subject" => user - } - }) - when is_map(user) do - get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "activate", - "subject" => [user] - } - }) - end - @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -416,24 +398,6 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} activated users: #{users_to_nicknames_string(users)}" end - @spec get_log_entry_message(ModerationLog) :: String.t() - def get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "deactivate", - "subject" => user - } - }) - when is_map(user) do - get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "deactivate", - "subject" => [user] - } - }) - end - @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -473,26 +437,6 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} removed tags: #{tags_string} from users: #{nicknames_to_string(nicknames)}" end - @spec get_log_entry_message(ModerationLog) :: String.t() - def get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "grant", - "subject" => user, - "permission" => permission - } - }) - when is_map(user) do - get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "grant", - "subject" => [user], - "permission" => permission - } - }) - end - @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ @@ -505,26 +449,6 @@ def get_log_entry_message(%ModerationLog{ "@#{actor_nickname} made #{users_to_nicknames_string(users)} #{permission}" end - @spec get_log_entry_message(ModerationLog) :: String.t() - def get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "revoke", - "subject" => user, - "permission" => permission - } - }) - when is_map(user) do - get_log_entry_message(%ModerationLog{ - data: %{ - "actor" => %{"nickname" => actor_nickname}, - "action" => "revoke", - "subject" => [user], - "permission" => permission - } - }) - end - @spec get_log_entry_message(ModerationLog) :: String.t() def get_log_entry_message(%ModerationLog{ data: %{ diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 8746273c4..348fdedf1 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -591,7 +591,7 @@ def validate_character_limit(full_payload, _attachments) do limit = Pleroma.Config.get([:instance, :limit]) length = String.length(full_payload) - if length < limit do + if length <= limit do :ok else {:error, dgettext("errors", "The status is over the character limit")} diff --git a/mix.exs b/mix.exs index 266dcac27..bb86c38d0 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Pleroma.Mixfile do def project do [ app: :pleroma, - version: version("1.1.50"), + version: version("2.0.50"), elixir: "~> 1.8", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), diff --git a/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs b/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs new file mode 100644 index 000000000..d1c8539e1 --- /dev/null +++ b/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs @@ -0,0 +1,9 @@ +defmodule Pleroma.Repo.Migrations.FixModerationLogSubjects do + use Ecto.Migration + + def change do + execute( + "update moderation_log set data = safe_jsonb_set(data, '{subject}', safe_jsonb_set('[]'::jsonb, '{0}', data->'subject')) where jsonb_typeof(data->'subject') != 'array' and data->>'action' = ANY('{revoke,grant,activate,deactivate,delete}');" + ) + end +end diff --git a/priv/static/adminfe/index.html b/priv/static/adminfe/index.html index b0bdb162d..e2db408c3 100644 --- a/priv/static/adminfe/index.html +++ b/priv/static/adminfe/index.html @@ -1 +1 @@ -Admin FE
\ No newline at end of file +Admin FE
\ No newline at end of file diff --git a/priv/static/adminfe/static/js/app.30262183.js b/priv/static/adminfe/static/js/app.30262183.js deleted file mode 100644 index c872d448f..000000000 Binary files a/priv/static/adminfe/static/js/app.30262183.js and /dev/null differ diff --git a/priv/static/adminfe/static/js/app.30262183.js.map b/priv/static/adminfe/static/js/app.30262183.js.map deleted file mode 100644 index 3711b8a98..000000000 Binary files a/priv/static/adminfe/static/js/app.30262183.js.map and /dev/null differ diff --git a/priv/static/adminfe/static/js/app.55df3157.js b/priv/static/adminfe/static/js/app.55df3157.js new file mode 100644 index 000000000..d1a37af1c Binary files /dev/null and b/priv/static/adminfe/static/js/app.55df3157.js differ diff --git a/priv/static/adminfe/static/js/app.55df3157.js.map b/priv/static/adminfe/static/js/app.55df3157.js.map new file mode 100644 index 000000000..740783b80 Binary files /dev/null and b/priv/static/adminfe/static/js/app.55df3157.js.map differ diff --git a/priv/static/index.html b/priv/static/index.html index 557ee5849..4304bdcbb 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -1 +1 @@ -Pleroma
\ No newline at end of file +Pleroma
\ No newline at end of file diff --git a/priv/static/static/font/fontello.1582927362782.woff2 b/priv/static/static/font/fontello.1582927362782.woff2 deleted file mode 100644 index 147707460..000000000 Binary files a/priv/static/static/font/fontello.1582927362782.woff2 and /dev/null differ diff --git a/priv/static/static/font/fontello.1582927362782.eot b/priv/static/static/font/fontello.1583594169021.eot similarity index 99% rename from priv/static/static/font/fontello.1582927362782.eot rename to priv/static/static/font/fontello.1583594169021.eot index bd848d613..f822a48a3 100644 Binary files a/priv/static/static/font/fontello.1582927362782.eot and b/priv/static/static/font/fontello.1583594169021.eot differ diff --git a/priv/static/static/font/fontello.1582927362782.svg b/priv/static/static/font/fontello.1583594169021.svg similarity index 100% rename from priv/static/static/font/fontello.1582927362782.svg rename to priv/static/static/font/fontello.1583594169021.svg diff --git a/priv/static/static/font/fontello.1582927362782.ttf b/priv/static/static/font/fontello.1583594169021.ttf similarity index 99% rename from priv/static/static/font/fontello.1582927362782.ttf rename to priv/static/static/font/fontello.1583594169021.ttf index 82691040e..5ed36e9aa 100644 Binary files a/priv/static/static/font/fontello.1582927362782.ttf and b/priv/static/static/font/fontello.1583594169021.ttf differ diff --git a/priv/static/static/font/fontello.1582927362782.woff b/priv/static/static/font/fontello.1583594169021.woff similarity index 98% rename from priv/static/static/font/fontello.1582927362782.woff rename to priv/static/static/font/fontello.1583594169021.woff index 8c8b4043d..408c26afb 100644 Binary files a/priv/static/static/font/fontello.1582927362782.woff and b/priv/static/static/font/fontello.1583594169021.woff differ diff --git a/priv/static/static/font/fontello.1583594169021.woff2 b/priv/static/static/font/fontello.1583594169021.woff2 new file mode 100644 index 000000000..b963e9489 Binary files /dev/null and b/priv/static/static/font/fontello.1583594169021.woff2 differ diff --git a/priv/static/static/fontello.1581007281335.css b/priv/static/static/fontello.1581007281335.css deleted file mode 100644 index 2c747b4ae..000000000 Binary files a/priv/static/static/fontello.1581007281335.css and /dev/null differ diff --git a/priv/static/static/fontello.1582927362782.css b/priv/static/static/fontello.1582927362782.css deleted file mode 100644 index 1889379ff..000000000 Binary files a/priv/static/static/fontello.1582927362782.css and /dev/null differ diff --git a/priv/static/static/fontello.1581425930672.css b/priv/static/static/fontello.1583594169021.css similarity index 89% rename from priv/static/static/fontello.1581425930672.css rename to priv/static/static/fontello.1583594169021.css index 70a43d019..c096e6103 100644 Binary files a/priv/static/static/fontello.1581425930672.css and b/priv/static/static/fontello.1583594169021.css differ diff --git a/priv/static/static/js/app.128bd8b808a3b5b6da6b.js b/priv/static/static/js/app.128bd8b808a3b5b6da6b.js deleted file mode 100644 index 8d36b0c36..000000000 Binary files a/priv/static/static/js/app.128bd8b808a3b5b6da6b.js and /dev/null differ diff --git a/priv/static/static/js/app.128bd8b808a3b5b6da6b.js.map b/priv/static/static/js/app.128bd8b808a3b5b6da6b.js.map deleted file mode 100644 index e53b74277..000000000 Binary files a/priv/static/static/js/app.128bd8b808a3b5b6da6b.js.map and /dev/null differ diff --git a/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js b/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js new file mode 100644 index 000000000..7ef7a5f12 Binary files /dev/null and b/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js differ diff --git a/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js.map b/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js.map new file mode 100644 index 000000000..163f78149 Binary files /dev/null and b/priv/static/static/js/app.5c94bdec79a7d0f3cfcb.js.map differ diff --git a/priv/static/static/static-fe.css b/priv/static/static/static-fe.css deleted file mode 100644 index 19c56387b..000000000 Binary files a/priv/static/static/static-fe.css and /dev/null differ diff --git a/priv/static/sw-pleroma.js b/priv/static/sw-pleroma.js index 87455aa6a..88e8fcd5a 100644 Binary files a/priv/static/sw-pleroma.js and b/priv/static/sw-pleroma.js differ diff --git a/restarter/lib/pleroma.ex b/restarter/lib/pleroma.ex index d7817909d..7f08c637c 100644 --- a/restarter/lib/pleroma.ex +++ b/restarter/lib/pleroma.ex @@ -3,11 +3,21 @@ defmodule Restarter.Pleroma do require Logger + @init_state %{need_reboot: false, rebooted: false, after_boot: false} + def start_link(_) do GenServer.start_link(__MODULE__, [], name: __MODULE__) end - def init(_), do: {:ok, %{need_reboot?: false}} + def init(_), do: {:ok, @init_state} + + def rebooted? do + GenServer.call(__MODULE__, :rebooted?) + end + + def rebooted do + GenServer.cast(__MODULE__, :rebooted) + end def need_reboot? do GenServer.call(__MODULE__, :need_reboot?) @@ -29,41 +39,51 @@ def restart_after_boot(env) do GenServer.cast(__MODULE__, {:after_boot, env}) end + def handle_call(:rebooted?, _from, state) do + {:reply, state[:rebooted], state} + end + def handle_call(:need_reboot?, _from, state) do - {:reply, state[:need_reboot?], state} + {:reply, state[:need_reboot], state} + end + + def handle_cast(:rebooted, state) do + {:noreply, Map.put(state, :rebooted, true)} + end + + def handle_cast(:need_reboot, %{need_reboot: true} = state), do: {:noreply, state} + + def handle_cast(:need_reboot, state) do + {:noreply, Map.put(state, :need_reboot, true)} end def handle_cast(:refresh, _state) do - {:noreply, %{need_reboot?: false}} - end - - def handle_cast(:need_reboot, %{need_reboot?: true} = state), do: {:noreply, state} - - def handle_cast(:need_reboot, state) do - {:noreply, Map.put(state, :need_reboot?, true)} + {:noreply, @init_state} end def handle_cast({:restart, :test, _}, state) do Logger.warn("pleroma restarted") - {:noreply, Map.put(state, :need_reboot?, false)} + {:noreply, Map.put(state, :need_reboot, false)} end def handle_cast({:restart, _, delay}, state) do Process.sleep(delay) do_restart(:pleroma) - {:noreply, Map.put(state, :need_reboot?, false)} + {:noreply, Map.put(state, :need_reboot, false)} end def handle_cast({:after_boot, _}, %{after_boot: true} = state), do: {:noreply, state} def handle_cast({:after_boot, :test}, state) do Logger.warn("pleroma restarted") - {:noreply, Map.put(state, :after_boot, true)} + state = %{state | after_boot: true, rebooted: true} + {:noreply, state} end def handle_cast({:after_boot, _}, state) do do_restart(:pleroma) - {:noreply, Map.put(state, :after_boot, true)} + state = %{state | after_boot: true, rebooted: true} + {:noreply, state} end defp do_restart(app) do diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 299d968db..b80523160 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -202,13 +202,15 @@ test "it returns error when status is empty and no attachments" do CommonAPI.post(user, %{"status" => ""}) end - test "it returns error when character limit is exceeded" do + test "it validates character limits are correctly enforced" do Pleroma.Config.put([:instance, :limit], 5) user = insert(:user) assert {:error, "The status is over the character limit"} = CommonAPI.post(user, %{"status" => "foobar"}) + + assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"}) end test "it can handle activities that expire" do