diff options
Diffstat (limited to 'lib/polyjuice/client/endpoint/get_media_download.ex')
-rw-r--r-- | lib/polyjuice/client/endpoint/get_media_download.ex | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/lib/polyjuice/client/endpoint/get_media_download.ex b/lib/polyjuice/client/endpoint/get_media_download.ex index 2a00e86..7bd9e35 100644 --- a/lib/polyjuice/client/endpoint/get_media_download.ex +++ b/lib/polyjuice/client/endpoint/get_media_download.ex @@ -34,14 +34,11 @@ defmodule Polyjuice.Client.Endpoint.GetMediaDownload do ] defimpl Polyjuice.Client.Endpoint.Proto do - def http_spec( - %{ - url: mxc_url, - allow_remote: allow_remote, - filename: filename - }, - base_url - ) do + def http_spec(%{ + url: mxc_url, + allow_remote: allow_remote, + filename: filename + }) do e = &URI.encode_www_form/1 {server_name, media_id} = @@ -68,24 +65,15 @@ defmodule Polyjuice.Client.Endpoint.GetMediaDownload do filename_part = if is_binary(filename), do: "/" <> e.(filename), else: "" - url = %{ - URI.merge( - base_url, - "#{Polyjuice.Client.prefix_media_r0()}/download/#{e.(server_name)}/#{e.(media_id)}#{ - filename_part - }" - ) - | query: if(allow_remote, do: nil, else: "allow_remote=false") - } - - %Polyjuice.Client.Endpoint.HttpSpec{ - method: :get, + Polyjuice.Client.Endpoint.HttpSpec.get( + :media_r0, + "download/#{e.(server_name)}/#{e.(media_id)}#{filename_part}", + query: if(!allow_remote, do: [allow_remote: "false"]), headers: [ {"Accept", "*/*"} ], - url: to_string(url), stream_response: true - } + ) end def transform_http_result(req, status_code, resp_headers, body) do |