~singpolyma/sgx-jmp

ref: 39685c1c2aafdab9f97846cc1c6154c4ca34af32 sgx-jmp/lib/web_register_manager.rb -rw-r--r-- 483 bytes
39685c1cStephen Paul Weber Registrations that start on the web will have a tel selected already 1 year, 7 months 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
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class WebRegisterManager
	def initialize
		@tel_map = Hash.new { ChooseTel.new }
	end

	def []=(jid, tel)
		@tel_map[jid.to_s] = HaveTel.new(tel)
	end

	def [](jid)
		@tel_map[jid.to_s]
	end

	def choose_tel(iq)
		self[iq.from.stripped].choose_tel(iq)
	end

	class HaveTel
		def initialize(tel)
			@tel = tel
		end

		def choose_tel(iq)
			EMPromise.resolve([iq, @tel])
		end
	end

	class ChooseTel
		def choose_tel(_iq)
			raise "TODO"
		end
	end
end