Merge branch 'linkify' into 'develop'
authorlain <lain@soykaf.club>
Tue, 21 Jul 2020 19:35:43 +0000 (19:35 +0000)
committerlain <lain@soykaf.club>
Tue, 21 Jul 2020 19:35:43 +0000 (19:35 +0000)
AutoLinker --> Linkify, update to latest version

See merge request pleroma/pleroma!2677

13 files changed:
.gitlab/issue_templates/Bug.md
CHANGELOG.md
docs/API/differences_in_mastoapi_responses.md
lib/pleroma/gopher/server.ex
lib/pleroma/http/http.ex
lib/pleroma/web/api_spec/operations/account_operation.ex
lib/pleroma/web/mastodon_api/views/instance_view.ex
lib/pleroma/web/templates/o_auth/mfa/recovery.html.eex
lib/pleroma/web/templates/o_auth/mfa/totp.html.eex
test/pagination_test.exs
test/upload/filter/anonymize_filename_test.exs
test/uploaders/local_test.exs
test/web/mastodon_api/controllers/account_controller_test.exs

index 9ce9b69182441ad145ebcf5dacfa0994954072bb..dd0d6eb247746c332fcb56abec8a16a2a31440ea 100644 (file)
@@ -8,9 +8,7 @@
 
 ### Environment
 
-* Installation type:
-  - [ ] OTP
-  - [ ] From source
+* Installation type (OTP or From Source):
 * Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE): 
 * Elixir version (`elixir -v` for from source installations, N/A for OTP):
 * Operating system:
index b124b59e1bfeb1bf96c3bfbbe422e25c8b692dad..f4397ec3c9c48b18ff1896be1c7045237c3c9f2a 100644 (file)
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
   has been simplified down to `block_from_strangers`.
 - **Breaking:** Notification Settings API option for hiding push notification
   contents has been renamed to `hide_notification_contents`
+- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
 </details>
 
 <details>
@@ -67,7 +68,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 <details>
   <summary>API Changes</summary>
-- Mastodon API: Add pleroma.parents_visible field to statuses.
+
+- Mastodon API: Add pleroma.parent_visible field to statuses.
 - Mastodon API: Extended `/api/v1/instance`.
 - Mastodon API: Support for `include_types` in `/api/v1/notifications`.
 - Mastodon API: Added `/api/v1/notifications/:id/dismiss` endpoint.
@@ -121,6 +123,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Follow request notifications
 <details>
   <summary>API Changes</summary>
+
 - Admin API: `GET /api/pleroma/admin/need_reboot`.
 </details>
 
@@ -188,6 +191,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - **Breaking**: Using third party engines for user recommendation
 <details>
   <summary>API Changes</summary>
+
 - **Breaking**: AdminAPI: migrate_from_db endpoint
 </details>
 
index c4a9c6dade9aeadfe12140475e359091151623ce..38865dc68a8b4393a7c40d23eceacebf1a7bf434 100644 (file)
@@ -236,6 +236,7 @@ Has theses additional parameters (which are the same as in Pleroma-API):
 - `pleroma.metadata.features`: A list of supported features
 - `pleroma.metadata.federation`: The federation restrictions of this instance
 - `pleroma.metadata.fields_limits`: A list of values detailing the length and count limitation for various instance-configurable fields.
+- `pleroma.metadata.post_formats`: A list of the allowed post format types
 - `vapid_public_key`: The public key needed for push messages
 
 ## Markers
index 3d56d50a9d16765a1d61574edabbda2066363879..e9f54c4c0077ec276131d69054ed02d69690cd95 100644 (file)
@@ -96,16 +96,18 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
 
   def response("/main/public") do
     posts =
-      ActivityPub.fetch_public_activities(%{"type" => ["Create"], "local_only" => true})
-      |> render_activities
+      %{type: ["Create"], local_only: true}
+      |> ActivityPub.fetch_public_activities()
+      |> render_activities()
 
     info("Welcome to the Public Timeline!") <> posts <> ".\r\n"
   end
 
   def response("/main/all") do
     posts =
-      ActivityPub.fetch_public_activities(%{"type" => ["Create"]})
-      |> render_activities
+      %{type: ["Create"]}
+      |> ActivityPub.fetch_public_activities()
+      |> render_activities()
 
     info("Welcome to the Federated Timeline!") <> posts <> ".\r\n"
   end
@@ -130,13 +132,14 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
   def response("/users/" <> nickname) do
     with %User{} = user <- User.get_cached_by_nickname(nickname) do
       params = %{
-        "type" => ["Create"],
-        "actor_id" => user.ap_id
+        type: ["Create"],
+        actor_id: user.ap_id
       }
 
       activities =
-        ActivityPub.fetch_public_activities(params)
-        |> render_activities
+        params
+        |> ActivityPub.fetch_public_activities()
+        |> render_activities()
 
       info("Posts by #{user.nickname}") <> activities <> ".\r\n"
     else
index 6128bc4cf94d5ac863a72d9dbe5922b9259eba29..b37b3fa8927c252a9b357e51d5635ca20f5d2376 100644 (file)
@@ -69,7 +69,8 @@ defmodule Pleroma.HTTP do
         request = build_request(method, headers, options, url, body, params)
 
         adapter = Application.get_env(:tesla, :adapter)
-        client = Tesla.client([Pleroma.HTTP.Middleware.FollowRedirects], adapter)
+
+        client = Tesla.client(adapter_middlewares(adapter), adapter)
 
         maybe_limit(
           fn ->
@@ -107,4 +108,10 @@ defmodule Pleroma.HTTP do
   defp maybe_limit(fun, _, _) do
     fun.()
   end
+
+  defp adapter_middlewares(Tesla.Adapter.Gun) do
+    [Pleroma.HTTP.Middleware.FollowRedirects]
+  end
+
+  defp adapter_middlewares(_), do: []
 end
index 952d9347b0013721efaa4a038744609038d07641..50c8e0242e0b161bda0787bbff5b4cb3dd2e82e1 100644 (file)
@@ -159,6 +159,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
         "Accounts which follow the given account, if network is not hidden by the account owner.",
       parameters: [
         %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+        Operation.parameter(:id, :query, :string, "ID of the resource owner"),
         with_relationships_param() | pagination_params()
       ],
       responses: %{
@@ -177,6 +178,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
         "Accounts which the given account is following, if network is not hidden by the account owner.",
       parameters: [
         %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+        Operation.parameter(:id, :query, :string, "ID of the resource owner"),
         with_relationships_param() | pagination_params()
       ],
       responses: %{200 => Operation.response("Accounts", "application/json", array_of_accounts())}
index 5deb0d7ed60ba4f71edfdf49a97e1dbb7a7fad98..cd3bc7f00c525f5413a6be3e38613dc44e3b9167 100644 (file)
@@ -41,7 +41,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
           account_activation_required: Keyword.get(instance, :account_activation_required),
           features: features(),
           federation: federation(),
-          fields_limits: fields_limits()
+          fields_limits: fields_limits(),
+          post_formats: Config.get([:instance, :allowed_post_formats])
         },
         vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
       }
index 750f653860d0b02d7854699a0c1ad35e7b926396..5ab59b57b1be9a1e963ea95402be5dce3a3dda07 100644 (file)
@@ -10,7 +10,7 @@
 <%= form_for @conn, mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
 <div class="input">
   <%= label f, :code, "Recovery code" %>
-  <%= text_input f, :code %>
+  <%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, spellcheck: false] %>
   <%= hidden_input f, :mfa_token, value: @mfa_token %>
   <%= hidden_input f, :state, value: @state %>
   <%= hidden_input f, :redirect_uri, value: @redirect_uri %>
index af6e546b0b852e33f471d3af0c02124187ae6f91..af85777ebb6117f78768da25b6868833de81e8c7 100644 (file)
@@ -10,7 +10,7 @@
 <%= form_for @conn, mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
 <div class="input">
   <%= label f, :code, "Authentication code" %>
-  <%= text_input f, :code %>
+  <%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, pattern: "[0-9]*", spellcheck: false] %>
   <%= hidden_input f, :mfa_token, value: @mfa_token %>
   <%= hidden_input f, :state, value: @state %>
   <%= hidden_input f, :redirect_uri, value: @redirect_uri %>
index 9165427aee6030584eb4edb199091f86082bcedf..e526f23e89731c27fa0c63476aaced445748ab38 100644 (file)
@@ -54,6 +54,20 @@ defmodule Pleroma.PaginationTest do
 
       assert length(paginated) == 1
     end
+
+    test "handles id gracefully", %{notes: notes} do
+      id = Enum.at(notes, 1).id |> Integer.to_string()
+
+      paginated =
+        Pagination.fetch_paginated(Object, %{
+          id: "9s99Hq44Cnv8PKBwWG",
+          max_id: id,
+          limit: 20,
+          offset: 0
+        })
+
+      assert length(paginated) == 1
+    end
   end
 
   describe "offset" do
index 2d5c580f1ca4b909bd1c8aa814a1249e59a5a5b5..adff70f574272f2a6a682bf27898ada2950f85fb 100644 (file)
@@ -9,6 +9,8 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
   alias Pleroma.Upload
 
   setup do
+    File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
+
     upload_file = %Upload{
       name: "an… image.jpg",
       content_type: "image/jpg",
index ae2cfef94261b0a20c68dc884bcc4990a0d3b264..18122ff6c372c98c74230dcfb9790d0178bfd92e 100644 (file)
@@ -14,6 +14,7 @@ defmodule Pleroma.Uploaders.LocalTest do
 
   describe "put_file/1" do
     test "put file to local folder" do
+      File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
       file_path = "local_upload/files/image.jpg"
 
       file = %Pleroma.Upload{
@@ -32,6 +33,7 @@ defmodule Pleroma.Uploaders.LocalTest do
 
   describe "delete_file/1" do
     test "deletes local file" do
+      File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
       file_path = "local_upload/files/image.jpg"
 
       file = %Pleroma.Upload{
index 9c7b5e9b22394389f9536e78a3743bfaeee1d4e7..c304487eae581373957b7c04ee475ee627c0ee7d 100644 (file)
@@ -583,6 +583,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
                |> get("/api/v1/accounts/#{user.id}/followers?max_id=#{follower3_id}")
                |> json_response_and_validate_schema(200)
 
+      assert [%{"id" => ^follower2_id}, %{"id" => ^follower1_id}] =
+               conn
+               |> get(
+                 "/api/v1/accounts/#{user.id}/followers?id=#{user.id}&limit=20&max_id=#{
+                   follower3_id
+                 }"
+               )
+               |> json_response_and_validate_schema(200)
+
       res_conn = get(conn, "/api/v1/accounts/#{user.id}/followers?limit=1&max_id=#{follower3_id}")
 
       assert [%{"id" => ^follower2_id}] = json_response_and_validate_schema(res_conn, 200)
@@ -654,6 +663,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
       assert id2 == following2.id
       assert id1 == following1.id
 
+      res_conn =
+        get(
+          conn,
+          "/api/v1/accounts/#{user.id}/following?id=#{user.id}&limit=20&max_id=#{following3.id}"
+        )
+
+      assert [%{"id" => id2}, %{"id" => id1}] = json_response_and_validate_schema(res_conn, 200)
+      assert id2 == following2.id
+      assert id1 == following1.id
+
       res_conn =
         get(conn, "/api/v1/accounts/#{user.id}/following?limit=1&max_id=#{following3.id}")