From: Ivan Tashkinov Date: Fri, 11 Sep 2020 14:19:58 +0000 (+0300) Subject: Merge remote-tracking branch 'remotes/origin/develop' into media-preview-proxy X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0bda85857e8f320ee7b91d8203fd621e1e2d5180;hp=-c;p=akkoma Merge remote-tracking branch 'remotes/origin/develop' into media-preview-proxy # Conflicts: # lib/pleroma/instances/instance.ex --- 0bda85857e8f320ee7b91d8203fd621e1e2d5180 diff --combined config/config.exs index 1a4b400f6,88c47fd03..93c930937 --- a/config/config.exs +++ b/config/config.exs @@@ -424,8 -424,6 +424,8 @@@ config :pleroma, :media_proxy proxy_opts: [ redirect_on_failure: false, max_body_length: 25 * 1_048_576, + # Note: max_read_duration defaults to Pleroma.ReverseProxy.max_read_duration_default/1 + max_read_duration: 30_000, http: [ follow_redirect: true, pool: :media @@@ -440,13 -438,6 +440,13 @@@ config :pleroma, Pleroma.Web.MediaProxy config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Script, script_path: nil +# Note: media preview proxy depends on media proxy to be enabled +config :pleroma, :media_preview_proxy, + enabled: false, + thumbnail_max_width: 600, + thumbnail_max_height: 600, + image_quality: 85 + config :pleroma, :chat, enabled: true config :phoenix, :format_encoders, json: Jason @@@ -539,6 -530,7 +539,7 @@@ config :pleroma, Oban log: false, queues: [ activity_expiration: 10, + token_expiration: 5, federator_incoming: 50, federator_outgoing: 50, web_push: 50, @@@ -552,8 -544,6 +553,6 @@@ ], plugins: [Oban.Plugins.Pruner], crontab: [ - {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}, - {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker}, {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}, {"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker} ] @@@ -664,7 -654,7 +663,7 @@@ config :pleroma, :rate_limit account_confirmation_resend: {8_640_000, 5}, ap_routes: {60_000, 15} - config :pleroma, Pleroma.ActivityExpiration, enabled: true + config :pleroma, Pleroma.Workers.PurgeExpiredActivity, enabled: true, min_lifetime: 600 config :pleroma, Pleroma.Plugs.RemoteIp, enabled: true @@@ -752,8 -742,8 +751,8 @@@ config :pleroma, :pools ], media: [ size: 50, - max_waiting: 10, - recv_timeout: 10_000 + max_waiting: 20, + recv_timeout: 15_000 ], upload: [ size: 25, diff --combined config/description.exs index d1c99d002,82c7bc6a7..c8e709730 --- a/config/description.exs +++ b/config/description.exs @@@ -1880,7 -1880,6 +1880,7 @@@ config :pleroma, :config_description, suggestions: [ redirect_on_failure: false, max_body_length: 25 * 1_048_576, + max_read_duration: 30_000, http: [ follow_redirect: true, pool: :media @@@ -1901,11 -1900,6 +1901,11 @@@ "Limits the content length to be approximately the " <> "specified length. It is validated with the `content-length` header and also verified when proxying." }, + %{ + key: :max_read_duration, + type: :integer, + description: "Timeout (in milliseconds) of GET request to remote URI." + }, %{ key: :http, label: "HTTP", @@@ -1952,35 -1946,6 +1952,35 @@@ } ] }, + %{ + group: :pleroma, + key: :media_preview_proxy, + type: :group, + description: "Media preview proxy", + children: [ + %{ + key: :enabled, + type: :boolean, + description: + "Enables proxying of remote media preview to the instance's proxy. Requires enabled media proxy." + }, + %{ + key: :thumbnail_max_width, + type: :integer, + description: "Max width of preview thumbnail." + }, + %{ + key: :thumbnail_max_height, + type: :integer, + description: "Max height of preview thumbnail." + }, + %{ + key: :image_quality, + type: :integer, + description: "Quality of the output. Ranges from 0 (min quality) to 100 (max quality)." + } + ] + }, %{ group: :pleroma, key: Pleroma.Web.MediaProxy.Invalidation.Http, @@@ -2325,8 -2290,6 +2325,6 @@@ type: {:list, :tuple}, description: "Settings for cron background jobs", suggestions: [ - {"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}, - {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker}, {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}, {"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker} ] @@@ -2509,14 -2472,20 +2507,20 @@@ }, %{ group: :pleroma, - key: Pleroma.ActivityExpiration, + key: Pleroma.Workers.PurgeExpiredActivity, type: :group, - description: "Expired activity settings", + description: "Expired activities settings", children: [ %{ key: :enabled, type: :boolean, - description: "Whether expired activities will be sent to the job queue to be deleted" + description: "Enables expired activities addition & deletion" + }, + %{ + key: :min_lifetime, + type: :integer, + description: "Minimum lifetime for ephemeral activity (in seconds)", + suggestions: [600] } ] }, diff --combined lib/pleroma/instances/instance.ex index ad7764f05,6948651c7..f0f601469 --- a/lib/pleroma/instances/instance.ex +++ b/lib/pleroma/instances/instance.ex @@@ -156,14 -156,14 +156,12 @@@ defmodule Pleroma.Instances.Instance d defp scrape_favicon(%URI{} = instance_uri) do try do with {:ok, %Tesla.Env{body: html}} <- - Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], - adapter: [pool: :media] - ), + Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], pool: :media), - favicon_rel <- - html - |> Floki.parse_document!() - |> Floki.attribute("link[rel=icon]", "href") - |> List.first(), - favicon <- URI.merge(instance_uri, favicon_rel) |> to_string(), - true <- is_binary(favicon) do + {_, [favicon_rel | _]} when is_binary(favicon_rel) <- + {:parse, + html |> Floki.parse_document!() |> Floki.attribute("link[rel=icon]", "href")}, + {_, favicon} when is_binary(favicon) <- + {:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do favicon else _ -> nil diff --combined lib/pleroma/web/mastodon_api/views/status_view.ex index 0882d680e,ca42917fc..4f7f27f35 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@@ -8,7 -8,6 +8,6 @@@ defmodule Pleroma.Web.MastodonAPI.Statu require Pleroma.Constants alias Pleroma.Activity - alias Pleroma.ActivityExpiration alias Pleroma.HTML alias Pleroma.Object alias Pleroma.Repo @@@ -245,8 -244,8 +244,8 @@@ expires_at = with true <- client_posted_this_activity, - %ActivityExpiration{scheduled_at: scheduled_at} <- - ActivityExpiration.get_by_activity_id(activity.id) do + %Oban.Job{scheduled_at: scheduled_at} <- + Pleroma.Workers.PurgeExpiredActivity.get_expiration(activity.id) do scheduled_at else _ -> nil @@@ -433,7 -432,6 +432,7 @@@ [attachment_url | _] = attachment["url"] media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image" href = attachment_url["href"] |> MediaProxy.url() + href_preview = attachment_url["href"] |> MediaProxy.preview_url() type = cond do @@@ -449,7 -447,7 +448,7 @@@ id: to_string(attachment["id"] || hash_id), url: href, remote_url: href, - preview_url: href, + preview_url: href_preview, text_url: href, type: type, description: attachment["name"],