Method: Notifaction::Type::Base#fire_hooks

Defined in:
lib/notifaction/type.rb

#fire_hooks(payload) ⇒ Object

Since:

  • 0.3.0



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/notifaction/type.rb', line 52

def fire_hooks(payload)
  mux = Mutex.new

  th = Thread.new do
    mux.synchronize do
      hooks = @user_conf.hooks

      return if hooks.nil?

      hooks.each do |uri|
        uri = URI.parse(uri)

        response = Net::HTTP.post_form(uri, payload)
        response.code.to_i < 300
      end
    end
  end.join.exit

  th.status == false
end