~singpolyma/sgx-jmp

sgx-jmp/lib/ibr_repo.rb -rw-r--r-- 466 bytes
4ace3417Stephen Paul Weber Log errors from rev.ai 8 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require "blather"
require "lazy_object"
require "value_semantics/monkey_patched"

class IBRRepo
	value_semantics do
		iq_manager Anything(), default: LazyObject.new { IQ_MANAGER }
	end

	def registered?(jid, from:)
		ibr = Blather::Stanza::Iq::IBR.new(:get, jid)
		ibr.from = from

		iq_manager.write(ibr).then do |result|
			if result.respond_to?(:registered?) && result.registered?
				result
			else
				false
			end
		end
	end
end