summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--config/config.exs1
-rw-r--r--docs/configuration/cheatsheet.md12
-rw-r--r--lib/pleroma/application.ex10
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex8
-rw-r--r--test/http/request_builder_test.exs10
6 files changed, 38 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68a9d93d8..e44c892ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -82,6 +82,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Mastodon API: Fix private and direct statuses not being filtered out from the public timeline for an authenticated user (`GET /api/v1/timelines/public`)
- Mastodon API: Inability to get some local users by nickname in `/api/v1/accounts/:id_or_nickname`
+- Admin API: Error when trying to update reports in the "old" format
</details>
## [1.1.6] - 2019-11-19
diff --git a/config/config.exs b/config/config.exs
index 1e36d3314..b60ffef7d 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -209,6 +209,7 @@ config :tesla, adapter: Tesla.Adapter.Hackney
config :pleroma, :http,
proxy_url: nil,
send_user_agent: true,
+ user_agent: :default,
adapter: [
ssl_options: [
# Workaround for remote server certificate chain issues
diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md
index 07d9a1d45..dc2f55229 100644
--- a/docs/configuration/cheatsheet.md
+++ b/docs/configuration/cheatsheet.md
@@ -348,7 +348,17 @@ Available caches:
* `:activity_pub` - activity pub routes (except question activities). Defaults to `nil` (no expiration).
* `:activity_pub_question` - activity pub routes (question activities). Defaults to `30_000` (30 seconds).
-## :hackney_pools
+## HTTP client
+
+### :http
+
+* `proxy_url`: an upstream proxy to fetch posts and/or media with, (default: `nil`)
+* `send_user_agent`: should we include a user agent with HTTP requests? (default: `true`)
+* `user_agent`: what user agent should we use? (default: `:default`), must be string or `:default`
+* `adapter`: array of hackney options
+
+
+### :hackney_pools
Advanced. Tweaks Hackney (http client) connections pools.
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index 2b6a55f98..9dbd1e26b 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -17,8 +17,14 @@ defmodule Pleroma.Application do
def repository, do: @repository
def user_agent do
- info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
- named_version() <> "; " <> info
+ case Pleroma.Config.get([:http, :user_agent], :default) do
+ :default ->
+ info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
+ named_version() <> "; " <> info
+
+ custom ->
+ custom
+ end
end
# See http://elixir-lang.org/docs/stable/elixir/Application.html
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index c45662359..01aacbde3 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -903,7 +903,13 @@ defmodule Pleroma.Web.ActivityPub.Utils do
def strip_report_status_data(activity) do
[actor | reported_activities] = activity.data["object"]
- stripped_activities = Enum.map(reported_activities, & &1["id"])
+
+ stripped_activities =
+ Enum.map(reported_activities, fn
+ act when is_map(act) -> act["id"]
+ act when is_binary(act) -> act
+ end)
+
new_data = put_in(activity.data, ["object"], [actor | stripped_activities])
{:ok, %{activity | data: new_data}}
diff --git a/test/http/request_builder_test.exs b/test/http/request_builder_test.exs
index 170ca916f..80ef25d7b 100644
--- a/test/http/request_builder_test.exs
+++ b/test/http/request_builder_test.exs
@@ -16,11 +16,21 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
test "send pleroma user agent" do
Pleroma.Config.put([:http, :send_user_agent], true)
+ Pleroma.Config.put([:http, :user_agent], :default)
assert RequestBuilder.headers(%{}, []) == %{
headers: [{"User-Agent", Pleroma.Application.user_agent()}]
}
end
+
+ test "send custom user agent" do
+ Pleroma.Config.put([:http, :send_user_agent], true)
+ Pleroma.Config.put([:http, :user_agent], "totally-not-pleroma")
+
+ assert RequestBuilder.headers(%{}, []) == %{
+ headers: [{"User-Agent", "totally-not-pleroma"}]
+ }
+ end
end
describe "add_optional_params/3" do