forked from AkkomaGang/akkoma
Merge branch 'bugfix/tesla-query-params' into 'develop'
Make OStatus Work Again See merge request pleroma/pleroma!671
This commit is contained in:
commit
d1c40cbca0
2 changed files with 9 additions and 1 deletions
|
@ -31,12 +31,15 @@ def request(method, url, body \\ "", headers \\ [], options \\ []) do
|
||||||
process_request_options(options)
|
process_request_options(options)
|
||||||
|> process_sni_options(url)
|
|> process_sni_options(url)
|
||||||
|
|
||||||
|
params = Keyword.get(options, :params, [])
|
||||||
|
|
||||||
%{}
|
%{}
|
||||||
|> Builder.method(method)
|
|> Builder.method(method)
|
||||||
|> Builder.headers(headers)
|
|> Builder.headers(headers)
|
||||||
|> Builder.opts(options)
|
|> Builder.opts(options)
|
||||||
|> Builder.url(url)
|
|> Builder.url(url)
|
||||||
|> Builder.add_param(:body, :body, body)
|
|> Builder.add_param(:body, :body, body)
|
||||||
|
|> Builder.add_param(:query, :query, params)
|
||||||
|> Enum.into([])
|
|> Enum.into([])
|
||||||
|> (&Tesla.request(Connection.new(), &1)).()
|
|> (&Tesla.request(Connection.new(), &1)).()
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,6 +100,8 @@ def add_optional_params(request, definitions, [{key, value} | tail]) do
|
||||||
Map
|
Map
|
||||||
"""
|
"""
|
||||||
@spec add_param(map(), atom, atom, any()) :: map()
|
@spec add_param(map(), atom, atom, any()) :: map()
|
||||||
|
def add_param(request, :query, :query, values), do: Map.put(request, :query, values)
|
||||||
|
|
||||||
def add_param(request, :body, :body, value), do: Map.put(request, :body, value)
|
def add_param(request, :body, :body, value), do: Map.put(request, :body, value)
|
||||||
|
|
||||||
def add_param(request, :body, key, value) do
|
def add_param(request, :body, key, value) do
|
||||||
|
@ -107,7 +109,10 @@ def add_param(request, :body, key, value) do
|
||||||
|> Map.put_new_lazy(:body, &Tesla.Multipart.new/0)
|
|> Map.put_new_lazy(:body, &Tesla.Multipart.new/0)
|
||||||
|> Map.update!(
|
|> Map.update!(
|
||||||
:body,
|
:body,
|
||||||
&Tesla.Multipart.add_field(&1, key, Poison.encode!(value),
|
&Tesla.Multipart.add_field(
|
||||||
|
&1,
|
||||||
|
key,
|
||||||
|
Jason.encode!(value),
|
||||||
headers: [{:"Content-Type", "application/json"}]
|
headers: [{:"Content-Type", "application/json"}]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue