Skip to content

Commit

Permalink
Fix the issue with wrongly formatted slack
Browse files Browse the repository at this point in the history
  • Loading branch information
am-kantox committed Dec 2, 2024
1 parent 6e97e20 commit f23dac3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/telemetria/messenger/slack.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ defmodule Telemetria.Messenger.Slack do
do: post(unquote(level), message, opts)
end)

defp post(level, message, opts) do
defp post(level, message, opts) when is_binary(message) do
case Jason.decode(message) do
{:ok, json} ->
post(level, json, opts)

{:error, error} ->
post(level, %{error: inspect(error), fallback: message, description: message}, opts)
end
end

defp post(level, %{} = message, opts) do
json =
message
|> put_in([:emoji_icon], slack_icon(level))
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Telemetria.MixProject do
use Mix.Project

@app :telemetria
@version "0.21.0"
@version "0.21.1"

def project do
[
Expand Down

0 comments on commit f23dac3

Please sign in to comment.