summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/link_plugin.ex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/lsg_irc/link_plugin.ex11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/lsg_irc/link_plugin.ex b/lib/lsg_irc/link_plugin.ex
index ea6df0c..ced80b2 100644
--- a/lib/lsg_irc/link_plugin.ex
+++ b/lib/lsg_irc/link_plugin.ex
@@ -52,8 +52,8 @@ defmodule LSG.IRC.LinkPlugin do
defstruct [:client]
def init([]) do
- {:ok, _} = Registry.register(IRC.PubSub, "message", [])
- #{:ok, _} = Registry.register(IRC.PubSub, "message:telegram", [])
+ {:ok, _} = Registry.register(IRC.PubSub, "message", [plugin: __MODULE__])
+ #{:ok, _} = Registry.register(IRC.PubSub, "message:telegram", [plugin: __MODULE__])
Logger.info("Link handler started")
{:ok, %__MODULE__{}}
end
@@ -159,7 +159,7 @@ defmodule LSG.IRC.LinkPlugin do
{length, _} = Integer.parse(length)
handlers = Keyword.get(Application.get_env(:lsg, __MODULE__, [handlers: []]), :handlers)
- handler = Enum.reduce_while(handlers, nil, fn({module, opts}, acc) ->
+ handler = Enum.reduce_while(handlers, false, fn({module, opts}, acc) ->
module = Module.concat([module])
try do
case module.post_match(url, content_type, headers, opts) do
@@ -225,8 +225,9 @@ defmodule LSG.IRC.LinkPlugin do
end
end
- defp get_body(_, len, client, _, _acc) do
+ defp get_body(_, len, client, h, _acc) do
:hackney.close(client)
+ IO.inspect(h)
{:ok, "Error: file over 30"}
end
@@ -243,6 +244,8 @@ defmodule LSG.IRC.LinkPlugin do
{:error, status, _headers} ->
text = Plug.Conn.Status.reason_phrase(status)
{:ok, acc, "Error: HTTP #{text} (#{status})"}
+ {:error, {:tls_alert, {:handshake_failure, err}}} ->
+ {:ok, acc, "TLS Error: #{to_string(err)}"}
{:error, reason} ->
{:ok, acc, "Error: #{to_string(reason)}"}
end