@@ 318,24 318,30 @@ end
command :execute?, node: "web-register", sessionid: nil do |iq|
sentry_hub = new_sentry_hub(iq, name: iq.node)
- jid = iq.form.field("jid")&.value.to_s.strip
- tel = iq.form.field("tel")&.value.to_s.strip
- if iq.from.stripped != CONFIG[:web_register][:from]
- BLATHER << iq.as_error("forbidden", :auth)
- elsif jid == "" || tel !~ /\A\+\d+\Z/
- reply_with_note(iq, "Invalid JID or telephone number.", type: :error)
- else
- IQ_MANAGER.write(Blather::Stanza::Iq::Command.new.tap { |cmd|
- cmd.to = CONFIG[:web_register][:to]
- cmd.from = CONFIG[:component][:jid]
- cmd.node = "push-register"
- cmd.form.fields = [var: "to", value: jid]
- cmd.form.type = "submit"
- }).then { |result|
- final_jid = result.form.field("from")&.value.to_s.strip
- web_register_manager[final_jid] = tel
- BLATHER << iq.reply.tap { |reply| reply.status = :completed }
- }.catch { |e| panic(e, sentry_hub) }
+
+ begin
+ jid = iq.form.field("jid")&.value.to_s.strip
+ tel = iq.form.field("tel")&.value.to_s.strip
+ hub.current_scope.set_user(jid: jid, tel: tel)
+ if iq.from.stripped != CONFIG[:web_register][:from]
+ BLATHER << iq.as_error("forbidden", :auth)
+ elsif jid == "" || tel !~ /\A\+\d+\Z/
+ reply_with_note(iq, "Invalid JID or telephone number.", type: :error)
+ else
+ IQ_MANAGER.write(Blather::Stanza::Iq::Command.new.tap { |cmd|
+ cmd.to = CONFIG[:web_register][:to]
+ cmd.from = CONFIG[:component][:jid]
+ cmd.node = "push-register"
+ cmd.form.fields = [var: "to", value: jid]
+ cmd.form.type = "submit"
+ }).then { |result|
+ final_jid = result.form.field("from")&.value.to_s.strip
+ web_register_manager[final_jid] = tel
+ BLATHER << iq.reply.tap { |reply| reply.status = :completed }
+ }.catch { |e| panic(e, sentry_hub) }
+ end
+ rescue StandardError => e
+ sentry_hub.capture_exception(e)
end
end