1# frozen_string_literal: true
2
3require "pg/em/connection_pool"
4require "bandwidth"
5require "bigdecimal"
6require "blather/client/dsl" # Require this first to not auto-include
7require "blather/client"
8require "braintree"
9require "date"
10require "dhall"
11require "em-hiredis"
12require "em_promise"
13require "ougai"
14require "ruby-bandwidth-iris"
15require "sentry-ruby"
16require "statsd-instrument"
17
18$stdout.sync = true
19LOG = Ougai::Logger.new($stdout)
20LOG.level = ENV.fetch("LOG_LEVEL", "info")
21LOG.formatter = Ougai::Formatters::Readable.new(
22 nil,
23 nil,
24 plain: !$stdout.isatty
25)
26Blather.logger = LOG
27EM::Hiredis.logger = LOG
28StatsD.logger = LOG
29LOG.info "Starting"
30
31Sentry.init do |config|
32 config.logger = LOG
33 config.breadcrumbs_logger = [:sentry_logger]
34end
35
36module SentryOugai
37 class SentryLogger
38 include Sentry::Breadcrumb::SentryLogger
39 include Singleton
40 end
41
42 def _log(severity, message=nil, ex=nil, data=nil, &block)
43 super
44 SentryLogger.instance.add_breadcrumb(severity, message || ex.to_s, &block)
45 end
46end
47LOG.extend SentryOugai
48
49CONFIG =
50 Dhall::Coder
51 .new(safe: Dhall::Coder::JSON_LIKE + [Symbol, Proc])
52 .load(
53 "(#{ARGV[0]}) : #{__dir__}/config-schema.dhall",
54 transform_keys: ->(k) { k&.to_sym }
55 )
56WEB_LISTEN =
57 if CONFIG[:web].is_a?(Hash)
58 [CONFIG[:web][:interface], CONFIG[:web][:port]]
59 else
60 [CONFIG[:web]]
61 end
62
63singleton_class.class_eval do
64 include Blather::DSL
65 Blather::DSL.append_features(self)
66end
67
68require_relative "lib/polyfill"
69require_relative "lib/alt_top_up_form"
70require_relative "lib/add_bitcoin_address"
71require_relative "lib/backend_sgx"
72require_relative "lib/bwmsgsv2_repo"
73require_relative "lib/bandwidth_tn_order"
74require_relative "lib/btc_sell_prices"
75require_relative "lib/buy_account_credit_form"
76require_relative "lib/command"
77require_relative "lib/command_list"
78require_relative "lib/customer"
79require_relative "lib/customer_info_form"
80require_relative "lib/customer_repo"
81require_relative "lib/electrum"
82require_relative "lib/expiring_lock"
83require_relative "lib/em"
84require_relative "lib/form_to_h"
85require_relative "lib/low_balance"
86require_relative "lib/port_in_order"
87require_relative "lib/payment_methods"
88require_relative "lib/paypal_done"
89require_relative "lib/registration"
90require_relative "lib/transaction"
91require_relative "lib/tel_selections"
92require_relative "lib/session_manager"
93require_relative "lib/statsd"
94require_relative "web"
95
96ELECTRUM = Electrum.new(**CONFIG[:electrum])
97EM::Hiredis::Client.load_scripts_from("./redis_lua")
98
99Faraday.default_adapter = :em_synchrony
100BandwidthIris::Client.global_options = {
101 account_id: CONFIG[:creds][:account],
102 username: CONFIG[:creds][:username],
103 password: CONFIG[:creds][:password]
104}
105BANDWIDTH_VOICE = Bandwidth::Client.new(
106 voice_basic_auth_user_name: CONFIG[:creds][:username],
107 voice_basic_auth_password: CONFIG[:creds][:password]
108).voice_client.client
109
110def new_sentry_hub(stanza, name: nil)
111 hub = Sentry.get_current_hub&.new_from_top
112 raise "Sentry.init has not been called" unless hub
113
114 hub.push_scope
115 hub.current_scope.clear_breadcrumbs
116 hub.current_scope.set_transaction_name(name) if name
117 hub.current_scope.set_user(jid: stanza.from.stripped.to_s)
118 hub
119end
120
121class AuthError < StandardError; end
122
123# Braintree is not async, so wrap in EM.defer for now
124class AsyncBraintree
125 def initialize(environment:, merchant_id:, public_key:, private_key:, **)
126 @gateway = Braintree::Gateway.new(
127 environment: environment,
128 merchant_id: merchant_id,
129 public_key: public_key,
130 private_key: private_key
131 )
132 @gateway.config.logger = LOG
133 end
134
135 def respond_to_missing?(m, *)
136 @gateway.respond_to?(m)
137 end
138
139 def method_missing(m, *args)
140 return super unless respond_to_missing?(m, *args)
141
142 EM.promise_defer(klass: PromiseChain) do
143 @gateway.public_send(m, *args)
144 end
145 end
146
147 class PromiseChain < EMPromise
148 def respond_to_missing?(*)
149 false # We don't actually know what we respond to...
150 end
151
152 def method_missing(m, *args)
153 return super if respond_to_missing?(m, *args)
154 self.then { |o| o.public_send(m, *args) }
155 end
156 end
157end
158
159BRAINTREE = AsyncBraintree.new(**CONFIG[:braintree])
160
161def panic(e, hub=nil)
162 (Thread.current[:log] || LOG).fatal(
163 "Error raised during event loop: #{e.class}",
164 e
165 )
166 if e.is_a?(::Exception)
167 (hub || Sentry).capture_exception(e, hint: { background: false })
168 else
169 (hub || Sentry).capture_message(e.to_s, hint: { background: false })
170 end
171 exit 1
172end
173
174EM.error_handler(&method(:panic))
175
176def poll_for_notify(db)
177 db.wait_for_notify_defer.then { |notify|
178 CustomerRepo.new.find(notify[:extra])
179 }.then(&LowBalance.method(:for)).then(&:notify!).then {
180 poll_for_notify(db)
181 }.catch(&method(:panic))
182end
183
184when_ready do
185 LOG.info "Ready"
186 BLATHER = self
187 REDIS = EM::Hiredis.connect
188 TEL_SELECTIONS = TelSelections.new
189 BTC_SELL_PRICES = BTCSellPrices.new(REDIS, CONFIG[:oxr_app_id])
190 DB = PG::EM::ConnectionPool.new(dbname: "jmp") do |conn|
191 conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn)
192 conn.type_map_for_queries = PG::BasicTypeMapForQueries.new(conn)
193 end
194
195 DB.hold do |conn|
196 conn.query("LISTEN low_balance")
197 conn.query("SELECT customer_id FROM balances WHERE balance < 5").each do |c|
198 conn.query("SELECT pg_notify('low_balance', $1)", c.values)
199 end
200 poll_for_notify(conn)
201 end
202
203 EM.add_periodic_timer(3600) do
204 ping = Blather::Stanza::Iq::Ping.new(:get, CONFIG[:server][:host])
205 ping.from = CONFIG[:component][:jid]
206 self << ping
207 end
208
209 Web.run(LOG.child, *WEB_LISTEN)
210end
211
212# workqueue_count MUST be 0 or else Blather uses threads!
213setup(
214 CONFIG[:component][:jid],
215 CONFIG[:component][:secret],
216 CONFIG[:server][:host],
217 CONFIG[:server][:port],
218 nil,
219 nil,
220 workqueue_count: 0
221)
222
223message to: /\Aaccount@/, body: /./ do |m|
224 StatsD.increment("deprecated_account_bot")
225
226 self << m.reply.tap do |out|
227 out.body = "This bot is deprecated. Please talk to xmpp:cheogram.com"
228 end
229end
230
231before(
232 :iq,
233 type: [:error, :result],
234 to: /\Acustomer_/,
235 from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/
236) { |iq| halt if IQ_MANAGER.fulfill(iq) }
237
238before nil, to: /\Acustomer_/, from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ do |s|
239 StatsD.increment("stanza_customer")
240
241 sentry_hub = new_sentry_hub(s, name: "stanza_customer")
242 CustomerRepo.new.find(
243 s.to.node.delete_prefix("customer_")
244 ).then { |customer|
245 sentry_hub.current_scope.set_user(
246 id: customer.customer_id,
247 jid: s.from.stripped.to_s
248 )
249 customer.stanza_to(s)
250 }.catch { |e| panic(e, sentry_hub) }
251 halt
252end
253
254ADDRESSES_NS = "http://jabber.org/protocol/address"
255message(
256 to: /\A#{CONFIG[:component][:jid]}\Z/,
257 from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/
258) do |m|
259 StatsD.increment("inbound_group_text")
260 sentry_hub = new_sentry_hub(m, name: "message")
261
262 address = m.find("ns:addresses", ns: ADDRESSES_NS).first
263 &.find("ns:address", ns: ADDRESSES_NS)
264 &.find { |el| el["jid"].to_s.start_with?("customer_") }
265 pass unless address
266
267 CustomerRepo.new.find_by_jid(address["jid"]).then { |customer|
268 m.from = m.from.with(domain: CONFIG[:component][:jid])
269 m.to = m.to.with(domain: customer.jid.domain)
270 address["jid"] = customer.jid.to_s
271 BLATHER << m
272 }.catch_only(CustomerRepo::NotFound) { |e|
273 BLATHER << iq.as_error("forbidden", :auth, e.message)
274 }.catch { |e| panic(e, sentry_hub) }
275end
276
277# Ignore groupchat messages
278# Especially if we have the component join MUC for notifications
279message(type: :groupchat) { true }
280
281def billable_message(m)
282 (m.body && !m.body.empty?) || m.find("ns:x", ns: OOB.registered_ns).first
283end
284
285message do |m|
286 StatsD.increment("message")
287
288 sentry_hub = new_sentry_hub(m, name: "message")
289 today = Time.now.utc.to_date
290 CustomerRepo.new.find_by_jid(m.from.stripped).then { |customer|
291 sentry_hub.current_scope.set_user(
292 id: customer.customer_id, jid: m.from.stripped.to_s
293 )
294 EMPromise.all([
295 (customer.incr_message_usage if billable_message(m)),
296 customer.stanza_from(m)
297 ]).then { customer }
298 }.then { |customer|
299 customer.message_usage((today..(today - 30))).then do |usage|
300 next unless usage > 500
301
302 ExpiringLock.new("jmp_usage_notify-#{customer.customer_id}").with do
303 BLATHER.join(CONFIG[:notify_admin], "sgx-jmp")
304 BLATHER.say(
305 CONFIG[:notify_admin],
306 "#{customer.customer_id} has used #{usage} messages since #{today - 30}",
307 :groupchat
308 )
309 end
310 end
311 }.catch { |e| panic(e, sentry_hub) }
312end
313
314message :error? do |m|
315 StatsD.increment("message_error")
316
317 LOG.error "MESSAGE ERROR", stanza: m
318end
319
320IQ_MANAGER = SessionManager.new(self, :id)
321COMMAND_MANAGER = SessionManager.new(
322 self,
323 :sessionid,
324 timeout: 60 * 60,
325 error_if: ->(s) { s.cancel? }
326)
327
328disco_info to: Blather::JID.new(CONFIG[:component][:jid]) do |iq|
329 reply = iq.reply
330 reply.identities = [{
331 name: "JMP.chat",
332 type: "sms",
333 category: "gateway"
334 }]
335 reply.features = [
336 "http://jabber.org/protocol/disco#info",
337 "http://jabber.org/protocol/commands"
338 ]
339 form = Blather::Stanza::X.find_or_create(reply.query)
340 form.type = "result"
341 form.fields = [
342 {
343 var: "FORM_TYPE",
344 type: "hidden",
345 value: "http://jabber.org/network/serverinfo"
346 }
347 ] + CONFIG[:xep0157]
348 self << reply
349end
350
351disco_info do |iq|
352 reply = iq.reply
353 reply.identities = [{
354 name: "JMP.chat",
355 type: "sms",
356 category: "client"
357 }]
358 reply.features = [
359 "urn:xmpp:receipts"
360 ]
361 self << reply
362end
363
364disco_items node: "http://jabber.org/protocol/commands" do |iq|
365 StatsD.increment("command_list")
366
367 sentry_hub = new_sentry_hub(iq, name: iq.node)
368 reply = iq.reply
369 reply.node = "http://jabber.org/protocol/commands"
370
371 CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new).find_by_jid(
372 iq.from.stripped
373 ).catch {
374 nil
375 }.then { |customer|
376 CommandList.for(customer)
377 }.then { |list|
378 reply.items = list.map do |item|
379 Blather::Stanza::DiscoItems::Item.new(
380 iq.to,
381 item[:node],
382 item[:name]
383 )
384 end
385 self << reply
386 }.catch { |e| panic(e, sentry_hub) }
387end
388
389iq "/iq/ns:services", ns: "urn:xmpp:extdisco:2" do |iq|
390 StatsD.increment("extdisco")
391
392 reply = iq.reply
393 reply << Nokogiri::XML::Builder.new {
394 services(xmlns: "urn:xmpp:extdisco:2") do
395 service(
396 type: "sip",
397 host: CONFIG[:sip_host]
398 )
399 end
400 }.doc.root
401
402 self << reply
403end
404
405Command.new(
406 "jabber:iq:register",
407 "Register",
408 list_for: ->(*) { true },
409 customer_repo: CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)
410) {
411 Command.customer.catch {
412 Sentry.add_breadcrumb(Sentry::Breadcrumb.new(message: "Customer.create"))
413 Command.execution.customer_repo.create(Command.execution.iq.from.stripped)
414 }.then { |customer|
415 Sentry.add_breadcrumb(Sentry::Breadcrumb.new(message: "Registration.for"))
416 Registration.for(customer, TEL_SELECTIONS).then(&:write)
417 }.then {
418 StatsD.increment("registration.completed")
419 }.catch_only(Command::Execution::FinalStanza) do |e|
420 StatsD.increment("registration.completed")
421 EMPromise.reject(e)
422 end
423}.register(self).then(&CommandList.method(:register))
424
425Command.new(
426 "info",
427 "Show Account Info",
428 list_for: ->(*) { true },
429 customer_repo: CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)
430) {
431 Command.customer.then(&:info).then do |info|
432 Command.finish do |reply|
433 form = Blather::Stanza::X.new(:result)
434 form.title = "Account Info"
435 form.fields = info.fields
436 reply.command << form
437 end
438 end
439}.register(self).then(&CommandList.method(:register))
440
441Command.new(
442 "usage",
443 "Show Monthly Usage"
444) {
445 report_for = (Date.today..(Date.today << 1))
446
447 Command.customer.then { |customer|
448 customer.usage_report(report_for)
449 }.then do |usage_report|
450 Command.finish do |reply|
451 reply.command << usage_report.form
452 end
453 end
454}.register(self).then(&CommandList.method(:register))
455
456# Commands that just pass through to the SGX
457{
458 "configure-calls" => ["Configure Calls"]
459}.each do |node, args|
460 Command.new(node, *args) {
461 Command.customer.then do |customer|
462 customer.stanza_from(Command.execution.iq)
463 end
464 }.register(self, guards: [node: node]).then(&CommandList.method(:register))
465end
466
467Command.new(
468 "ogm",
469 "Record Voicemail Greeting",
470 list_for: ->(fwd: nil, **) { !!fwd },
471 customer_repo: CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)
472) {
473 Command.customer.then do |customer|
474 BANDWIDTH_VOICE.create_call(
475 CONFIG[:creds][:account],
476 body: customer.fwd.create_call_request do |cc|
477 cc.from = customer.registered?.phone
478 cc.application_id = CONFIG[:sip][:app]
479 cc.answer_url = "#{CONFIG[:web_root]}/ogm/start?" \
480 "customer_id=#{customer.customer_id}"
481 end
482 )
483 Command.finish("You will now receive a call.")
484 end
485}.register(self).then(&CommandList.method(:register))
486
487Command.new(
488 "migrate billing",
489 "Switch from PayPal or expired trial to new billing",
490 list_for: ->(tel:, customer:, **) { tel && !customer&.currency },
491 customer_repo: CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)
492) {
493 EMPromise.all([
494 Command.customer,
495 Command.reply do |reply|
496 reply.allowed_actions = [:next]
497 reply.command << FormTemplate.render("migrate_billing")
498 end
499 ]).then do |(customer, iq)|
500 Registration::Payment.for(
501 iq, customer, customer.registered?.phone,
502 final_message: PaypalDone::MESSAGE,
503 finish: PaypalDone
504 ).then(&:write).catch_only(Command::Execution::FinalStanza) do |s|
505 BLATHER.join(CONFIG[:notify_admin], "sgx-jmp")
506 BLATHER.say(
507 CONFIG[:notify_admin],
508 "#{customer.customer_id} migrated to #{customer.currency}",
509 :groupchat
510 )
511 EMPromise.reject(s)
512 end
513 end
514}.register(self).then(&CommandList.method(:register))
515
516Command.new(
517 "credit cards",
518 "Credit Card Settings and Management"
519) {
520 Command.customer.then do |customer|
521 url = CONFIG[:credit_card_url].call(
522 customer.jid.to_s.gsub("\\", "%5C"),
523 customer.customer_id
524 )
525 desc = "Manage credits cards and settings"
526 Command.finish("#{desc}: #{url}") do |reply|
527 oob = OOB.find_or_create(reply.command)
528 oob.url = url
529 oob.desc = desc
530 end
531 end
532}.register(self).then(&CommandList.method(:register))
533
534Command.new(
535 "top up",
536 "Buy Account Credit by Credit Card",
537 list_for: ->(payment_methods: [], **) { !payment_methods.empty? },
538 format_error: ->(e) { "Failed to buy credit, system said: #{e.message}" }
539) {
540 Command.customer.then { |customer|
541 BuyAccountCreditForm.for(customer).then do |credit_form|
542 Command.reply { |reply|
543 reply.allowed_actions = [:complete]
544 credit_form.add_to_form(reply.form)
545 }.then do |iq|
546 Transaction.sale(customer, **credit_form.parse(iq.form))
547 end
548 end
549 }.then { |transaction|
550 transaction.insert.then do
551 Command.finish("#{transaction} added to your account balance.")
552 end
553 }.catch_only(BuyAccountCreditForm::AmountValidationError) do |e|
554 Command.finish(e.message, type: :error)
555 end
556}.register(self).then(&CommandList.method(:register))
557
558Command.new(
559 "alt top up",
560 "Buy Account Credit by Bitcoin, Mail, or Interac eTransfer",
561 list_for: ->(customer:, **) { !!customer&.currency }
562) {
563 Command.customer.then { |customer|
564 EMPromise.all([AltTopUpForm.for(customer), customer])
565 }.then do |(alt_form, customer)|
566 Command.reply { |reply|
567 reply.allowed_actions = [:complete]
568 reply.command << alt_form.form
569 }.then do |iq|
570 AddBitcoinAddress.for(iq, alt_form, customer).write
571 end
572 end
573}.register(self).then(&CommandList.method(:register))
574
575Command.new(
576 "referral codes",
577 "Refer a friend for free credit"
578) {
579 Command.customer.then(&:unused_invites).then do |invites|
580 if invites.empty?
581 Command.finish("You have no more invites right now, try again later.")
582 else
583 Command.finish do |reply|
584 reply.form.type = :result
585 reply.form.title = "Unused Invite Codes"
586 reply.form.instructions =
587 "Each of these codes is single use and gives the person using " \
588 "them a free month of JMP service. You will receive credit " \
589 "equivalent to one month of free service if they later become " \
590 "a paying customer."
591 FormTable.new(
592 invites.map { |i| [i] },
593 code: "Invite Code"
594 ).add_to_form(reply.form)
595 end
596 end
597 end
598}.register(self).then(&CommandList.method(:register))
599
600Command.new(
601 "reset sip account",
602 "Create or Reset SIP Account",
603 customer_repo: CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new)
604) {
605 Command.customer.then do |customer|
606 sip_account = customer.reset_sip_account
607 Command.reply { |reply|
608 reply.allowed_actions = [:next]
609 form = sip_account.form
610 form.type = :form
611 form.fields += [{
612 type: :boolean, var: "change_fwd",
613 label: "Should inbound calls forward to this SIP account?"
614 }]
615 reply.command << form
616 }.then do |fwd|
617 if ["1", "true"].include?(fwd.form.field("change_fwd")&.value.to_s)
618 # Migrate location if needed
619 BandwidthIris::SipPeer.new(
620 site_id: CONFIG[:bandwidth_site],
621 id: CONFIG[:bandwidth_peer]
622 ).move_tns([customer.registered?.phone])
623 customer.set_fwd(sip_account.uri).then do
624 Command.finish("Inbound calls will now forward to SIP.")
625 end
626 else
627 Command.finish
628 end
629 end
630 end
631}.register(self).then(&CommandList.method(:register))
632
633Command.new(
634 "lnp",
635 "Port in your number from another carrier",
636 list_for: ->(**) { true }
637) {
638 using FormToH
639
640 EMPromise.all([
641 Command.customer,
642 Command.reply do |reply|
643 reply.allowed_actions = [:next]
644 reply.command << FormTemplate.render("lnp")
645 end
646 ]).then do |(customer, iq)|
647 order = PortInOrder.new(iq.form.to_h.slice(
648 "BillingTelephoneNumber", "Subscriber", "WirelessInfo"
649 ).merge("CustomerOrderId" => customer.customer_id))
650 order_id = BandwidthIris::PortIn.create(order.to_h)[:order_id]
651 url = "https://dashboard.bandwidth.com/portal/r/a/" \
652 "#{CONFIG[:creds][:account]}/orders/portIn/#{order_id}"
653 BLATHER.join(CONFIG[:notify_admin], "sgx-jmp")
654 BLATHER.say(
655 CONFIG[:notify_admin],
656 "New port-in request for #{customer.customer_id}: #{url}",
657 :groupchat
658 )
659 Command.finish(
660 "Your port-in request has been accepted, " \
661 "support will contact you with next steps"
662 )
663 end
664}.register(self).then(&CommandList.method(:register))
665
666Command.new(
667 "customer info",
668 "Show Customer Info",
669 list_for: ->(customer: nil, **) { customer&.admin? }
670) {
671 Command.customer.then do |customer|
672 raise AuthError, "You are not an admin" unless customer&.admin?
673
674 customer_info = CustomerInfoForm.new
675 Command.reply { |reply|
676 reply.allowed_actions = [:next]
677 reply.command << customer_info.picker_form
678 }.then { |response|
679 customer_info.find_customer(response)
680 }.then do |target_customer|
681 target_customer.admin_info.then do |info|
682 Command.finish do |reply|
683 form = Blather::Stanza::X.new(:result)
684 form.title = "Customer Info"
685 form.fields = info.fields
686 reply.command << form
687 end
688 end
689 end
690 end
691}.register(self).then(&CommandList.method(:register))
692
693def reply_with_note(iq, text, type: :info)
694 reply = iq.reply
695 reply.status = :completed
696 reply.note_type = type
697 reply.note_text = text
698
699 self << reply
700end
701
702command :execute?, node: "web-register" do |iq|
703 StatsD.increment("command", tags: ["node:#{iq.node}"])
704
705 sentry_hub = new_sentry_hub(iq, name: iq.node)
706
707 begin
708 jid = iq.form.field("jid")&.value.to_s.strip
709 tel = iq.form.field("tel")&.value.to_s.strip
710 sentry_hub.current_scope.set_user(jid: jid, tel: tel)
711 if iq.from.stripped != CONFIG[:web_register][:from]
712 BLATHER << iq.as_error("forbidden", :auth)
713 elsif jid == "" || tel !~ /\A\+\d+\Z/
714 reply_with_note(iq, "Invalid JID or telephone number.", type: :error)
715 else
716 IQ_MANAGER.write(Blather::Stanza::Iq::Command.new.tap { |cmd|
717 cmd.to = CONFIG[:web_register][:to]
718 cmd.node = "push-register"
719 cmd.form.fields = [var: "to", value: jid]
720 cmd.form.type = "submit"
721 }).then { |result|
722 TEL_SELECTIONS.set(result.form.field("from")&.value.to_s.strip, tel)
723 }.then {
724 BLATHER << iq.reply.tap { |reply| reply.status = :completed }
725 }.catch { |e| panic(e, sentry_hub) }
726 end
727 rescue StandardError => e
728 sentry_hub.capture_exception(e)
729 end
730end
731
732command sessionid: /./ do |iq|
733 COMMAND_MANAGER.fulfill(iq)
734end
735
736iq type: [:result, :error] do |iq|
737 IQ_MANAGER.fulfill(iq)
738end
739
740iq type: [:get, :set] do |iq|
741 StatsD.increment("unknown_iq")
742
743 self << Blather::StanzaError.new(iq, "feature-not-implemented", :cancel)
744end