Commit 377184be132bfbcc784fa7281cfc69f2bd1009ab

Authored by Florian Unglaub
1 parent d1683958
Exists in master and in 1 other branch production

Wrap jabber notifications in a timeout block

app/models/notification_services/gtalk_service.rb
... ... @@ -41,18 +41,21 @@ class NotificationServices::GtalkService < NotificationService
41 41  
42 42 def create_notification(problem)
43 43 # build the xmpp client
44   - client = Jabber::Client.new(Jabber::JID.new(subdomain))
45   - client.connect(service)
46   - client.auth(api_token)
  44 + client = nil
  45 + Timeout.timeout(5) do
  46 + client = Jabber::Client.new(Jabber::JID.new(subdomain))
  47 + client.connect(service)
  48 + client.auth(api_token)
47 49  
48   - #has to look like this to be formatted properly in the client
49   - message = """#{problem.app.name}
  50 + #has to look like this to be formatted properly in the client
  51 + message = """#{problem.app.name}
50 52 #{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}
51 53 #{notification_description problem}"""
52 54  
53   - # post the issue to the xmpp room(s)
54   - send_to_users(client, message) unless user_id.blank?
55   - send_to_muc(client, message) unless room_id.blank?
  55 + # post the issue to the xmpp room(s)
  56 + send_to_users(client, message) unless user_id.blank?
  57 + send_to_muc(client, message) unless room_id.blank?
  58 + end
56 59 ensure
57 60 client.close unless client.nil?
58 61 end
... ...