Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 21 Jan 2021 17:20:35 +0000 (20:20 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 21 Jan 2021 17:20:35 +0000 (20:20 +0300)
# Conflicts:
# CHANGELOG.md

1  2 
CHANGELOG.md
config/description.exs
lib/pleroma/application.ex
test/pleroma/object_test.exs
test/pleroma/web/common_api_test.exs

diff --combined CHANGELOG.md
index 9a053156fe9f89e61fb5d2c98def7e3d32448398,e1dfeae01c00199f45de696ae910d63b94627242..29dd347a00503938172f199925cbdb73a6c950cf
@@@ -8,14 -8,16 +8,17 @@@ The format is based on [Keep a Changelo
  
  ### Changed
  
+ - **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
+ - **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
+ - **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
  - Polls now always return a `voters_count`, even if they are single-choice.
  - Admin Emails: The ap id is used as the user link in emails now.
  - Improved registration workflow for email confirmation and account approval modes.
- - **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
  - Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
  - Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
  - Admin API: Reports now ordered by newest
+ - Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders.
 +- Extracted object hashtags into separate table in order to improve hashtag timeline performance (via background migration in `Pleroma.Migrators.HashtagsTableMigrator`). 
  
  ### Added
  
@@@ -32,6 -34,8 +35,8 @@@
  - OAuth form improvements: users are remembered by their cookie, the CSS is overridable by the admin, and the style has been improved.
  - OAuth improvements and fixes: more secure session-based authentication (by token that could be revoked anytime), ability to revoke belonging OAuth token from any client etc.
  - Ability to set ActivityPub aliases for follower migration.
+ - Configurable background job limits for RichMedia (link previews) and MediaProxyWarmingPolicy
  
  <details>
    <summary>API Changes</summary>
@@@ -41,6 -45,7 +46,7 @@@
  - Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute.
  - Admin API: An endpoint to manage frontends.
  - Streaming API: Add follow relationships updates.
+ - WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types
  </details>
  
  ### Fixed
@@@ -48,6 -53,7 +54,7 @@@
  - Users with `is_discoverable` field set to false (default value) will appear in in-service search results but be hidden from external services (search bots etc.).
  - Streaming API: Posts and notifications are not dropped, when CLI task is executing.
  - Creating incorrect IPv4 address-style HTTP links when encountering certain numbers.
+ - Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private.
  
  <details>
    <summary>API Changes</summary>
  
  ## Unreleased (Patch)
  
+ ## [2.2.2] - 2020-01-18
  ### Fixed
  
- - Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
- - Emoji Reaction activity filtering from blocked and muted accounts.
  - StealEmojiPolicy creates dir for emojis, if it doesn't exist.
+ - Updated `elixir_make` to a non-retired version
+ ### Upgrade notes
+ 1. Restart Pleroma
  
  ## [2.2.1] - 2020-12-22
  
@@@ -77,6 -89,7 +90,7 @@@
  - Rich Media Previews sometimes showed the wrong preview due to a bug following redirects.
  - Fixes for the autolinker.
  - Forwarded reports duplication from Pleroma instances.
+ - Emoji Reaction activity filtering from blocked and muted accounts.
  
  - <details>
      <summary>API</summary>
diff --combined config/description.exs
index c73d50f7db82d13ba4e918611597ca70d8c4378b,715a0d0c36e731c6732acdc72607c19fcb44a80d..b48616b229d06a98be08a06bb7b1ecf81c3a4087
@@@ -149,18 -149,12 +149,12 @@@ config :pleroma, :config_description, 
          description: "S3 bucket namespace",
          suggestions: ["pleroma"]
        },
-       %{
-         key: :public_endpoint,
-         type: :string,
-         description: "S3 endpoint",
-         suggestions: ["https://s3.amazonaws.com"]
-       },
        %{
          key: :truncated_namespace,
          type: :string,
          description:
            "If you use S3 compatible service such as Digital Ocean Spaces or CDN, set folder name or \"\" etc." <>
-             " For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in public_endpoint."
+             " For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in Upload base_url."
        },
        %{
          key: :streaming_enabled,
          key: :show_reactions,
          type: :boolean,
          description: "Let favourites and emoji reactions be viewed through the API."
 +      },
 +      %{
 +        key: :improved_hashtag_timeline,
 +        type: :keyword,
 +        description:
 +          "If `true` / `:prefer_aggregation` / `:avoid_aggregation`, hashtags table and selected strategy will be used for hashtags timeline. When `false`, object-embedded hashtags will be used (slower). Is auto-set to `true` (unless overridden) when HashtagsTableMigrator completes."
        }
      ]
    },
          suggestions: [:text, :protobuf]
        }
      ]
+   },
+   %{
+     group: :pleroma,
+     key: ConcurrentLimiter,
+     type: :group,
+     description: "Limits configuration for background tasks.",
+     children: [
+       %{
+         key: Pleroma.Web.RichMedia.Helpers,
+         type: :keyword,
+         description: "Concurrent limits configuration for getting RichMedia for activities.",
+         suggestions: [max_running: 5, max_waiting: 5],
+         children: [
+           %{
+             key: :max_running,
+             type: :integer,
+             description: "Max running concurrently jobs.",
+             suggestion: [5]
+           },
+           %{
+             key: :max_waiting,
+             type: :integer,
+             description: "Max waiting jobs.",
+             suggestion: [5]
+           }
+         ]
+       },
+       %{
+         key: Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy,
+         type: :keyword,
+         description: "Concurrent limits configuration for MediaProxyWarmingPolicy.",
+         suggestions: [max_running: 5, max_waiting: 5],
+         children: [
+           %{
+             key: :max_running,
+             type: :integer,
+             description: "Max running concurrently jobs.",
+             suggestion: [5]
+           },
+           %{
+             key: :max_waiting,
+             type: :integer,
+             description: "Max waiting jobs.",
+             suggestion: [5]
+           }
+         ]
+       }
+     ]
    }
  ]
index a9a8fb9c21c331cc28406b1357985b903bfb2f74,9e262235eef83c86b2426924508699ac7c7dc1ef..d39451a9dcb8bf6b26fe018a8a2708e119b67295
@@@ -104,8 -104,7 +104,8 @@@ defmodule Pleroma.Application d
          chat_child(chat_enabled?()) ++
          [
            Pleroma.Web.Endpoint,
 -          Pleroma.Gopher.Server
 +          Pleroma.Gopher.Server,
 +          Pleroma.Migrators.HashtagsTableMigrator
          ]
  
      # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
  
    @spec limiters_setup() :: :ok
    def limiters_setup do
-     [Pleroma.Web.RichMedia.Helpers, Pleroma.Web.MediaProxy]
-     |> Enum.each(&ConcurrentLimiter.new(&1, 1, 0))
+     config = Config.get(ConcurrentLimiter, [])
+     [Pleroma.Web.RichMedia.Helpers, Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy]
+     |> Enum.each(fn module ->
+       mod_config = Keyword.get(config, module, [])
+       max_running = Keyword.get(mod_config, :max_running, 5)
+       max_waiting = Keyword.get(mod_config, :max_waiting, 5)
+       ConcurrentLimiter.new(module, max_running, max_waiting)
+     end)
    end
  end
index ee0d00f2b131d8b1dcb0c63ff4871745665351a0,db7678d5d183ce9ab41079792924fccefc6513b9..8320660a50cacc3ae51acbb96ba5e9948745da31
@@@ -5,13 -5,10 +5,13 @@@
  defmodule Pleroma.ObjectTest do
    use Pleroma.DataCase
    use Oban.Testing, repo: Pleroma.Repo
 +
    import ExUnit.CaptureLog
    import Pleroma.Factory
    import Tesla.Mock
 +
    alias Pleroma.Activity
 +  alias Pleroma.Hashtag
    alias Pleroma.Object
    alias Pleroma.Repo
    alias Pleroma.Tests.ObanHelpers
@@@ -81,8 -78,8 +81,8 @@@
      setup do: clear_config([:instance, :cleanup_attachments])
  
      test "Disabled via config" do
-       Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
-       Pleroma.Config.put([:instance, :cleanup_attachments], false)
+       clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+       clear_config([:instance, :cleanup_attachments], false)
  
        file = %Plug.Upload{
          content_type: "image/jpeg",
      end
  
      test "in subdirectories" do
-       Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
-       Pleroma.Config.put([:instance, :cleanup_attachments], true)
+       clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+       clear_config([:instance, :cleanup_attachments], true)
  
        file = %Plug.Upload{
          content_type: "image/jpeg",
      end
  
      test "with dedupe enabled" do
-       Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
-       Pleroma.Config.put([Pleroma.Upload, :filters], [Pleroma.Upload.Filter.Dedupe])
-       Pleroma.Config.put([:instance, :cleanup_attachments], true)
+       clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+       clear_config([Pleroma.Upload, :filters], [Pleroma.Upload.Filter.Dedupe])
+       clear_config([:instance, :cleanup_attachments], true)
  
        uploads_dir = Pleroma.Config.get!([Pleroma.Uploaders.Local, :uploads])
  
      end
  
      test "with objects that have legacy data.url attribute" do
-       Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
-       Pleroma.Config.put([:instance, :cleanup_attachments], true)
+       clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+       clear_config([:instance, :cleanup_attachments], true)
  
        file = %Plug.Upload{
          content_type: "image/jpeg",
      end
  
      test "With custom base_url" do
-       Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
-       Pleroma.Config.put([Pleroma.Upload, :base_url], "https://sub.domain.tld/dir/")
-       Pleroma.Config.put([:instance, :cleanup_attachments], true)
+       clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+       clear_config([Pleroma.Upload, :base_url], "https://sub.domain.tld/dir/")
+       clear_config([:instance, :cleanup_attachments], true)
  
        file = %Plug.Upload{
          content_type: "image/jpeg",
        assert updated_object.data["like_count"] == 1
      end
    end
 +
 +  describe ":hashtags association" do
 +    test "Hashtag records are created with Object record and updated on its change" do
 +      user = insert(:user)
 +
 +      {:ok, %{object: object}} =
 +        CommonAPI.post(user, %{status: "some text #hashtag1 #hashtag2 ..."})
 +
 +      assert [%Hashtag{name: "hashtag1"}, %Hashtag{name: "hashtag2"}] =
 +               Enum.sort_by(object.hashtags, & &1.name)
 +
 +      {:ok, object} = Object.update_data(object, %{"tag" => []})
 +
 +      assert [] = object.hashtags
 +
 +      object = Object.get_by_id(object.id) |> Repo.preload(:hashtags)
 +      assert [] = object.hashtags
 +
 +      {:ok, object} = Object.update_data(object, %{"tag" => ["abc", "def"]})
 +
 +      assert [%Hashtag{name: "abc"}, %Hashtag{name: "def"}] =
 +               Enum.sort_by(object.hashtags, & &1.name)
 +    end
 +  end
  end
index 209fa86f6cae5c4742ad435442d67d9c33aeed18,7067f1b59092ac9a840bf28be2331fce74a3afca..776bdce2005c5c49e6ad9ce5d80631090f1fb1c3
@@@ -493,7 -493,7 +493,7 @@@ defmodule Pleroma.Web.CommonAPITest d
  
      object = Object.normalize(activity, fetch: false)
  
 -    assert object.data["tag"] == ["2hu"]
 +    assert Object.tags(object) == ["2hu"]
    end
  
    test "it adds emoji in the object" do
        refute Visibility.visible_for_user?(announce_activity, nil)
      end
  
+     test "author can repeat own private statuses" do
+       author = insert(:user)
+       follower = insert(:user)
+       CommonAPI.follow(follower, author)
+       {:ok, activity} = CommonAPI.post(author, %{status: "cofe", visibility: "private"})
+       {:ok, %Activity{} = announce_activity} = CommonAPI.repeat(activity.id, author)
+       assert Visibility.is_private?(announce_activity)
+       refute Visibility.visible_for_user?(announce_activity, nil)
+       assert Visibility.visible_for_user?(activity, follower)
+       assert {:error, :not_found} = CommonAPI.repeat(activity.id, follower)
+     end
      test "favoriting a status" do
        user = insert(:user)
        other_user = insert(:user)