~singpolyma/sgx-jmp

ref: 94b7b998d195a73afe638a3d9da926edd402e0b5 sgx-jmp/lib/web_register_manager.rb -rw-r--r-- 537 bytes
94b7b998Stephen Paul Weber hotfix 1 year, 3 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

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

		def choose_tel
			EMPromise.resolve(@tel)
		end
	end

	class ChooseTel
		def choose_tel
			Command.finish(
				"You have not chosen a phone number yet, please return to " \
				"https://jmp.chat and choose one now.",
				type: :error
			)
		end
	end
end