Skip to content

Commit

Permalink
fix(Rest): sending files via keyword lists
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed Aug 16, 2018
1 parent 8caa4b2 commit aab5e95
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ defmodule Crux.Rest do
def create_message(%Message{channel_id: channel_id}, args), do: create_message(channel_id, args)
def create_message(%Channel{id: channel_id}, args), do: create_message(channel_id, args)

def create_message(channel_id, not_map) when not is_map(not_map),
do: create_message(channel_id, Map.new(not_map))

def create_message(channel_id, %{files: files} = args) when is_number(channel_id) do
Enum.reduce_while(files, [], fn file, acc ->
with {:error, error} <- Util.map_file(file) do
Expand Down Expand Up @@ -133,7 +136,7 @@ defmodule Crux.Rest do
end
end

def create_message(channel_id, args), do: real_create_message(channel_id, Map.new(args))
def create_message(channel_id, args), do: real_create_message(channel_id, args)

defp real_create_message(channel_id, args, disposition \\ []) do
Rest.Base.queue(:post, Endpoints.channel_messages(channel_id), args, disposition)
Expand Down

0 comments on commit aab5e95

Please sign in to comment.