An Elixir toolkit for the AT Protocol. hexdocs.pm/atex
elixir bluesky atproto decentralization
25
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(xrpc): properly fix raw_input issue

+15 -25
+15 -25
lib/atex/xrpc.ex
··· 168 168 end 169 169 170 170 def post(client, %{__struct__: module} = procedure, opts) do 171 - has_raw_input? = 172 - if procedure.raw_input do 173 - if Code.ensure_loaded?(module) and function_exported?(module, :content_type, 0) do 174 - headers = Keyword.get(opts, :headers, []) 171 + # Require content-type header if `raw_input` is passed. 172 + if match?(%{raw_input: _body}, procedure) do 173 + if Code.ensure_loaded?(module) and function_exported?(module, :content_type, 0) do 174 + headers = Keyword.get(opts, :headers, []) 175 175 176 - has_content_type? = 177 - Enum.any?(headers, fn {k, _} -> String.downcase(k) == "content-type" end) 176 + has_content_type? = 177 + Enum.any?(headers, fn {k, _} -> String.downcase(k) == "content-type" end) 178 178 179 - unless has_content_type? do 180 - raise """ 181 - content-type header is required when sending raw_input for #{module.id()}. 182 - Expected: #{module.content_type()} 183 - """ 184 - end 179 + unless has_content_type? do 180 + raise """ 181 + content-type header is required when sending raw_input for #{module.id()}. 182 + Expected: #{module.content_type()} 183 + """ 185 184 end 186 - 187 - true 188 - else 189 - false 190 185 end 186 + end 191 187 192 188 opts = 193 - if has_raw_input? do 194 - opts 195 - |> put_params(procedure) 196 - |> Keyword.put(:body, procedure.raw_input) 197 - else 198 - opts 199 - |> put_params(procedure) 200 - |> put_body(procedure) 201 - end 189 + opts 190 + |> put_params(procedure) 191 + |> put_body(procedure) 202 192 203 193 output_struct = Module.concat(module, Output) 204 194 output_exists = Code.ensure_loaded?(output_struct)