Merge branch 'develop' into 'fix/2412-filters'
authorfeld <feld@feld.me>
Wed, 3 Feb 2021 14:23:23 +0000 (14:23 +0000)
committerfeld <feld@feld.me>
Wed, 3 Feb 2021 14:23:23 +0000 (14:23 +0000)
# Conflicts:
#   CHANGELOG.md

1  2 
CHANGELOG.md
config/config.exs
lib/pleroma/web/api_spec/operations/filter_operation.ex
test/support/factory.ex

diff --combined CHANGELOG.md
index 226fa2bbfcac4c8eaac6b1f422f87da0ce7a6dec,b3aa52219ca825309c2e6e54097c5d41862ccede..47009abc93f37a41ff552a3e4401ac39b04652aa
@@@ -10,17 -10,26 +10,26 @@@ The format is based on [Keep a Changelo
  
  - **Breaking**: Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
  - **Breaking**: Changed `mix pleroma.user toggle_activated` to `mix pleroma.user activate/deactivate`
- - **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
- - **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
- - **Breaking**: AdminAPI changed User field `deactivated` to `is_active`
  - 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.
  - 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.
  - Improved Apache webserver support: updated sample configuration, MediaProxy cache invalidation verified with the included sample script
+ - Improve OAuth 2.0 provider support. A missing `fqn` field was added to the response, but does not expose the user's email address.
+ <details>
+   <summary>API Changes</summary>
+ - **Breaking:** AdminAPI changed User field `confirmation_pending` to `is_confirmed`
+ - **Breaking:** AdminAPI changed User field `approval_pending` to `is_approved`
+ - **Breaking**: AdminAPI changed User field `deactivated` to `is_active`
+ - **Breaking:** AdminAPI `GET /api/pleroma/admin/users/:nickname_or_id/statuses` changed response format and added the number of total users posts.
+ - **Breaking:** AdminAPI `GET /api/pleroma/admin/instances/:instance/statuses` changed response format and added the number of total users posts.
+ - Admin API: Reports now ordered by newest
+ </details>
  
  ### Added
  
@@@ -38,7 -47,7 +47,7 @@@
  - 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
+ - Ability to define custom HTTP headers per each frontend
  
  <details>
    <summary>API Changes</summary>
  - 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
+ - WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types.
+ - Mastodon API: Add monthly active users to `/api/v1/instance` (`pleroma.stats.mau`).
+ - Mastodon API: Home, public, hashtag & list timelines accept `only_media`, `remote` & `local` parameters for filtration.
+ - Mastodon API: `/api/v1/accounts/:id` & `/api/v1/mutes` endpoints accept `with_relationships` parameter and return filled `pleroma.relationship` field.
  </details>
  
  ### Fixed
  - 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.
  - Tag URLs in statuses are now absolute
+ - Removed duplicate jobs to purge expired activities
+ - File extensions of some attachments were incorrectly changed. This feature has been disabled for now.
+ - Mix task pleroma.instance creates missing parent directories if the configuration or SQL output paths are changed.
  
  <details>
    <summary>API Changes</summary>
    - Mastodon API: Current user is now included in conversation if it's the only participant.
    - Mastodon API: Fixed last_status.account being not filled with account data.
+   - Mastodon API: Fix not being able to add or remove multiple users at once in lists.
    - Mastodon API: Fixed own_votes being not returned with poll data.
+   - Mastodon API: Fixed creation of scheduled posts with polls.
 +  - Mastodon API: Support for expires_in/expires_at in the Filters.
  </details>
  
  ## Unreleased (Patch)
diff --combined config/config.exs
index 715524e84507d82a8f29b0e2e7bba757dd1941a2,b9af250c5f2f1e28fb6d1fcad718512e7946e8a0..0fbca06f3f8f8d2cd35c0cdef8a39c0fb378efea
@@@ -543,7 -543,6 +543,7 @@@ config :pleroma, Oban
    queues: [
      activity_expiration: 10,
      token_expiration: 5,
 +    filter_expiration: 1,
      backup: 1,
      federator_incoming: 50,
      federator_outgoing: 50,
@@@ -726,7 -725,10 +726,10 @@@ config :pleroma, :frontends
        "git" => "https://git.pleroma.social/pleroma/fedi-fe",
        "build_url" =>
          "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
-       "ref" => "master"
+       "ref" => "master",
+       "custom-http-headers" => [
+         {"service-worker-allowed", "/"}
+       ]
      },
      "admin-fe" => %{
        "name" => "admin-fe",
index 9374a78685c18ba1a1994a172d9fa3abbace8a33,42b8fc93126519bc856c1a60f6e6dc4c0fd8013d..5102921bc35eae7607554c2052ca45eea09190e3
@@@ -6,7 -6,6 +6,7 @@@ defmodule Pleroma.Web.ApiSpec.FilterOpe
    alias OpenApiSpex.Operation
    alias OpenApiSpex.Schema
    alias Pleroma.Web.ApiSpec.Helpers
 +  alias Pleroma.Web.ApiSpec.Schemas.ApiError
    alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
  
    def open_api_operation(action) do
  
    def index_operation do
      %Operation{
-       tags: ["apps"],
-       summary: "View all filters",
+       tags: ["Filters"],
+       summary: "All filters",
        operationId: "FilterController.index",
        security: [%{"oAuth" => ["read:filters"]}],
        responses: %{
 -        200 => Operation.response("Filters", "application/json", array_of_filters())
 +        200 => Operation.response("Filters", "application/json", array_of_filters()),
 +        403 => Operation.response("Error", "application/json", ApiError)
        }
      }
    end
  
    def create_operation do
      %Operation{
-       tags: ["apps"],
+       tags: ["Filters"],
        summary: "Create a filter",
        operationId: "FilterController.create",
        requestBody: Helpers.request_body("Parameters", create_request(), required: true),
        security: [%{"oAuth" => ["write:filters"]}],
 -      responses: %{200 => Operation.response("Filter", "application/json", filter())}
 +      responses: %{
 +        200 => Operation.response("Filter", "application/json", filter()),
 +        403 => Operation.response("Error", "application/json", ApiError)
 +      }
      }
    end
  
    def show_operation do
      %Operation{
-       tags: ["apps"],
-       summary: "View all filters",
+       tags: ["Filters"],
+       summary: "Filter",
        parameters: [id_param()],
        operationId: "FilterController.show",
        security: [%{"oAuth" => ["read:filters"]}],
        responses: %{
 -        200 => Operation.response("Filter", "application/json", filter())
 +        200 => Operation.response("Filter", "application/json", filter()),
 +        403 => Operation.response("Error", "application/json", ApiError),
 +        404 => Operation.response("Error", "application/json", ApiError)
        }
      }
    end
  
    def update_operation do
      %Operation{
-       tags: ["apps"],
+       tags: ["Filters"],
        summary: "Update a filter",
        parameters: [id_param()],
        operationId: "FilterController.update",
        requestBody: Helpers.request_body("Parameters", update_request(), required: true),
        security: [%{"oAuth" => ["write:filters"]}],
        responses: %{
 -        200 => Operation.response("Filter", "application/json", filter())
 +        200 => Operation.response("Filter", "application/json", filter()),
 +        403 => Operation.response("Error", "application/json", ApiError)
        }
      }
    end
  
    def delete_operation do
      %Operation{
-       tags: ["apps"],
+       tags: ["Filters"],
        summary: "Remove a filter",
        parameters: [id_param()],
        operationId: "FilterController.delete",
@@@ -83,8 -75,7 +83,8 @@@
            Operation.response("Filter", "application/json", %Schema{
              type: :object,
              description: "Empty object"
 -          })
 +          }),
 +        403 => Operation.response("Error", "application/json", ApiError)
        }
      }
    end
            nullable: true,
            description: "Consider word boundaries?",
            default: true
 +        },
 +        expires_in: %Schema{
 +          nullable: true,
 +          type: :integer,
 +          description:
 +            "Number of seconds from now the filter should expire. Otherwise, null for a filter that doesn't expire."
          }
 -        # TODO: probably should implement filter expiration
 -        # expires_in: %Schema{
 -        #   type: :string,
 -        #   format: :"date-time",
 -        #   description:
 -        #     "ISO 8601 Datetime for when the filter expires. Otherwise,
 -        #  null for a filter that doesn't expire."
 -        # }
        },
        required: [:phrase, :context],
        example: %{
diff --combined test/support/factory.ex
index 284d573f970528f8d11b7e397559cf00d361a1d6,436e19409c5ab0f4701bea5aa4dd1f4e32ca4ecb..af4fff45b947c771e5d622b1ff7af73cf9108388
@@@ -104,6 -104,37 +104,37 @@@ defmodule Pleroma.Factory d
      }
    end
  
+   def attachment_note_factory(attrs \\ %{}) do
+     user = attrs[:user] || insert(:user)
+     {length, attrs} = Map.pop(attrs, :length, 1)
+     data = %{
+       "attachment" =>
+         Stream.repeatedly(fn -> attachment_data(user.ap_id, attrs[:href]) end)
+         |> Enum.take(length)
+     }
+     build(:note, Map.put(attrs, :data, data))
+   end
+   defp attachment_data(ap_id, href) do
+     href = href || sequence(:href, &"#{Pleroma.Web.Endpoint.url()}/media/#{&1}.jpg")
+     %{
+       "url" => [
+         %{
+           "href" => href,
+           "type" => "Link",
+           "mediaType" => "image/jpeg"
+         }
+       ],
+       "name" => "some name",
+       "type" => "Document",
+       "actor" => ap_id,
+       "mediaType" => "image/jpeg"
+     }
+   end
    def audio_factory(attrs \\ %{}) do
      text = sequence(:text, &"lain radio episode #{&1}")
  
      %Pleroma.Filter{
        user: build(:user),
        filter_id: sequence(:filter_id, & &1),
 -      phrase: "cofe"
 +      phrase: "cofe",
 +      context: ["home"]
      }
    end
  end