Skip to content

Commit

Permalink
fix(Functions.*emoji): roles is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed Aug 20, 2019
1 parent 3ae9c33 commit c0f2724
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/rest/functions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,12 @@ defmodule Crux.Rest.Functions do
|> Map.new()
|> Util.resolve_image_in_map(:image)
|> case do
%{:roles => [_ | _] = roles} = data ->
%{roles: [_ | _] = roles} = data ->
roles = Enum.map(roles, &Util.resolve_role_id/1)
Map.put(data, :roles, roles)
%{data | roles: roles}

data ->
data
end

:post
Expand All @@ -426,10 +429,10 @@ defmodule Crux.Rest.Functions do
data
|> Map.new()
|> case do
%{roles: roles} ->
Map.put(data, :roles, Enum.map(roles, &Util.resolve_role_id/1))
%{roles: roles} = data ->
%{data | roles: Enum.map(roles, &Util.resolve_role_id/1)}

_ ->
data ->
data
end

Expand Down

0 comments on commit c0f2724

Please sign in to comment.