Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ discourse_activity_pub:
client: true
activity_pub_send_user_agent:
default: true
hidden: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sites don't need to modify this, best to keep it hidden.

activity_pub_verbose_logging:
default: false
activity_pub_object_logging:
default: false
activity_pub_logs_max_days_old:
default: 60
min: 2
max: 365
max: 365
5 changes: 5 additions & 0 deletions lib/discourse_activity_pub/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def request(path, verb: :post, body: nil, headers: nil, params: nil)
opts[:body] = body.to_json if body
opts[:headers] = {}
opts[:headers]["Content-Type"] = "application/json" if body
if SiteSetting.activity_pub_send_user_agent
opts[:headers][
"User-Agent"
] = "Discourse-ActivityPub/#{::Discourse::VERSION::STRING} (+#{::Discourse.base_url})"
end
headers.each { |k, v| opts[:headers][k] = v } if headers

begin
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/discourse_activity_pub/auth/discourse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def expect_request(domain: "", path: "", body: nil, verb: :post, response: nil,
opts[:body] = body.to_json if body
opts[:headers] = {}
opts[:headers]["Content-Type"] = "application/json" if body
if SiteSetting.activity_pub_send_user_agent
opts[:headers][
"User-Agent"
] = "Discourse-ActivityPub/#{Discourse::VERSION::STRING} (+#{Discourse.base_url})"
end
headers.each { |k, v| opts[:headers][k] = v } if headers

Excon.expects(:send).with(verb, "https://#{domain}/#{path}", opts).returns(response)
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/discourse_activity_pub/auth/mastodon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def expect_request(domain: "", path: "", body: nil, verb: :post, response: nil,
opts[:body] = body.to_json if body
opts[:headers] = {}
opts[:headers]["Content-Type"] = "application/json" if body
if SiteSetting.activity_pub_send_user_agent
opts[:headers][
"User-Agent"
] = "Discourse-ActivityPub/#{Discourse::VERSION::STRING} (+#{Discourse.base_url})"
end
headers.each { |k, v| opts[:headers][k] = v } if headers

Excon.expects(:send).with(verb, "https://#{domain}/#{path}", opts).returns(response)
Expand Down