logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 32a940b86bd8f62a12fac191c84f0152667555e1
parent 606c9ae4b1ae6456fe4a17a9328c35ba87bbd652
Author: nicole mikołajczyk <git@mkljczk.pl>
Date:   Sun, 26 Oct 2025 23:32:01 +0100

Allow setting custom user-agent for fetching rich media content

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>

Diffstat:

Achangelog.d/rich-media-user-agent.add1+
Mconfig/description.exs5+++++
Mlib/pleroma/web/rich_media/helpers.ex7++++++-
3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/changelog.d/rich-media-user-agent.add b/changelog.d/rich-media-user-agent.add @@ -0,0 +1 @@ +Allow setting custom user-agent for fetching rich media content diff --git a/config/description.exs b/config/description.exs @@ -2131,6 +2131,11 @@ config :pleroma, :config_description, [ description: "Amount of milliseconds after which the HTTP request is forcibly terminated.", suggestions: [5_000] + }, + %{ + key: :user_agent, + type: :string, + description: "Custom User-Agent header to be used when fetching rich media content." } ] }, diff --git a/lib/pleroma/web/rich_media/helpers.ex b/lib/pleroma/web/rich_media/helpers.ex @@ -126,6 +126,11 @@ defmodule Pleroma.Web.RichMedia.Helpers do end defp req_headers do - [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}] + user_agent = Config.get([:rich_media, :user_agent], :default) + + case user_agent do + :default -> [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}] + custom -> [{"user-agent", custom}] + end end end