From 59d32c10d985ea328e291e3c912fd4b352c25945 Mon Sep 17 00:00:00 2001 From: timorl Date: Tue, 16 Apr 2024 08:02:13 +0200 Subject: [PATCH] Formatting --- lib/pleroma/web/plugs/o_auth_scopes_plug.ex | 4 +- lib/pleroma/web/telemetry.ex | 69 +++++++++---------- test/mix/tasks/pleroma/instance_test.exs | 2 + .../attachment_validator_test.exs | 15 ++-- test/support/factory.ex | 19 +++-- 5 files changed, 53 insertions(+), 56 deletions(-) diff --git a/lib/pleroma/web/plugs/o_auth_scopes_plug.ex b/lib/pleroma/web/plugs/o_auth_scopes_plug.ex index e4d098a7d..f017c8bc7 100644 --- a/lib/pleroma/web/plugs/o_auth_scopes_plug.ex +++ b/lib/pleroma/web/plugs/o_auth_scopes_plug.ex @@ -34,9 +34,7 @@ def perform(%Plug.Conn{assigns: assigns} = conn, %{scopes: scopes} = options) do permissions = Enum.join(missing_scopes, " #{op} ") error_message = - dgettext("errors", "Insufficient permissions: %{permissions}.", - permissions: permissions - ) + dgettext("errors", "Insufficient permissions: %{permissions}.", permissions: permissions) conn |> put_resp_content_type("application/json") diff --git a/lib/pleroma/web/telemetry.ex b/lib/pleroma/web/telemetry.ex index 269f9f238..0ddb2c903 100644 --- a/lib/pleroma/web/telemetry.ex +++ b/lib/pleroma/web/telemetry.ex @@ -151,41 +151,40 @@ defp summary_fallback_metrics(byte_unit \\ :byte) do # phoenix.router_dispatch.stop.duration # pleroma.repo.query.total_time # pleroma.repo.query.queue_time - dist_metrics = - [ - distribution("phoenix.endpoint.stop.duration.fdist", - event_name: [:phoenix, :endpoint, :stop], - measurement: :duration, - unit: {:native, :millisecond}, - reporter_options: [ - buckets: simple_buckets - ] - ), - distribution("pleroma.repo.query.decode_time.fdist", - event_name: [:pleroma, :repo, :query], - measurement: :decode_time, - unit: {:native, :millisecond}, - reporter_options: [ - buckets: simple_buckets_quick - ] - ), - distribution("pleroma.repo.query.query_time.fdist", - event_name: [:pleroma, :repo, :query], - measurement: :query_time, - unit: {:native, :millisecond}, - reporter_options: [ - buckets: simple_buckets - ] - ), - distribution("pleroma.repo.query.idle_time.fdist", - event_name: [:pleroma, :repo, :query], - measurement: :idle_time, - unit: {:native, :millisecond}, - reporter_options: [ - buckets: simple_buckets - ] - ) - ] + dist_metrics = [ + distribution("phoenix.endpoint.stop.duration.fdist", + event_name: [:phoenix, :endpoint, :stop], + measurement: :duration, + unit: {:native, :millisecond}, + reporter_options: [ + buckets: simple_buckets + ] + ), + distribution("pleroma.repo.query.decode_time.fdist", + event_name: [:pleroma, :repo, :query], + measurement: :decode_time, + unit: {:native, :millisecond}, + reporter_options: [ + buckets: simple_buckets_quick + ] + ), + distribution("pleroma.repo.query.query_time.fdist", + event_name: [:pleroma, :repo, :query], + measurement: :query_time, + unit: {:native, :millisecond}, + reporter_options: [ + buckets: simple_buckets + ] + ), + distribution("pleroma.repo.query.idle_time.fdist", + event_name: [:pleroma, :repo, :query], + measurement: :idle_time, + unit: {:native, :millisecond}, + reporter_options: [ + buckets: simple_buckets + ] + ) + ] vm_metrics = sum_counter_pair("vm.memory.total", diff --git a/test/mix/tasks/pleroma/instance_test.exs b/test/mix/tasks/pleroma/instance_test.exs index a2b73e0c8..d650bdf7c 100644 --- a/test/mix/tasks/pleroma/instance_test.exs +++ b/test/mix/tasks/pleroma/instance_test.exs @@ -93,8 +93,10 @@ test "running gen" do assert generated_config =~ "password: \"dbpass\"" assert generated_config =~ "configurable_from_database: true" assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]" + assert generated_config =~ "filters: [Pleroma.Upload.Filter.Exiftool.StripLocation, Pleroma.Upload.Filter.Exiftool.ReadDescription]" + assert generated_config =~ "base_url: \"https://media.pleroma.social/media\"" assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql() assert File.exists?(Path.expand("./test/instance/static/robots.txt")) diff --git a/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs index f8dec09d3..22a8d0899 100644 --- a/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs @@ -12,14 +12,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidatorTest do describe "attachments" do test "works with apng" do - attachment = - %{ - "mediaType" => "image/apng", - "name" => "", - "type" => "Document", - "url" => - "https://media.misskeyusercontent.com/io/2859c26e-cd43-4550-848b-b6243bc3fe28.apng" - } + attachment = %{ + "mediaType" => "image/apng", + "name" => "", + "type" => "Document", + "url" => + "https://media.misskeyusercontent.com/io/2859c26e-cd43-4550-848b-b6243bc3fe28.apng" + } assert {:ok, attachment} = AttachmentValidator.cast_and_validate(attachment) diff --git a/test/support/factory.ex b/test/support/factory.ex index e21b8fc1e..2a73a4ae6 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -559,16 +559,15 @@ def undo_activity_factory(attrs \\ %{}) do like_activity = attrs[:like_activity] || insert(:like_activity) attrs = Map.drop(attrs, [:like_activity]) - data = - %{ - "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), - "type" => "Undo", - "actor" => like_activity.data["actor"], - "to" => like_activity.data["to"], - "object" => like_activity.data["id"], - "published" => DateTime.utc_now() |> DateTime.to_iso8601(), - "context" => like_activity.data["context"] - } + data = %{ + "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), + "type" => "Undo", + "actor" => like_activity.data["actor"], + "to" => like_activity.data["to"], + "object" => like_activity.data["id"], + "published" => DateTime.utc_now() |> DateTime.to_iso8601(), + "context" => like_activity.data["context"] + } %Pleroma.Activity{ data: data,