Change summary
em_promise.rb | 10 ++++++++++
sgx-catapult.rb | 15 +++------------
2 files changed, 13 insertions(+), 12 deletions(-)
Detailed changes
@@ -20,6 +20,16 @@ class EMPromise < Promise
EM.next_tick { yield }
end
+ def wait
+ fiber = Fiber.current
+ resume = proc do |arg|
+ defer { fiber.resume(arg) }
+ end
+
+ self.then(resume, resume)
+ Fiber.yield
+ end
+
def self.reject(e)
new.tap { |promise| promise.reject(e) }
end
@@ -960,21 +960,16 @@ class WebhookHandler < Goliath::API
return [200, {}, "OK"]
end
- jid_key = "catapult_jid-" + users_num
-
if others_num[0] != '+'
# TODO: check that others_num actually a shortcode first
others_num +=
';phone-context=ca-us.phone-context.soprani.ca'
end
- conn = Hiredis::Connection.new
- conn.connect(ARGV[4], ARGV[5].to_i)
-
- conn.write ["EXISTS", jid_key]
- if conn.read == 0
- conn.disconnect
+ jid_key = "catapult_jid-#{users_num}"
+ bare_jid = REDIS.get(jid_key).promise.sync
+ if !bare_jid
puts "jid_key (#{jid_key}) DNE; Catapult misconfigured?"
# TODO: likely not appropriate; give error to Catapult?
@@ -984,10 +979,6 @@ class WebhookHandler < Goliath::API
return [200, {}, "OK"]
end
- conn.write ["GET", jid_key]
- bare_jid = conn.read
- conn.disconnect
-
msg = ''
case params['direction']
when 'in'