Skip to content
Browse files

Refactor Jabber MUC implementation

  • Loading branch information...
1 parent 827d890 commit c320894635a56e96be20a7e37a0039cbf98eb196 @bbhoss bbhoss committed Apr 17, 2012
Showing with 13 additions and 18 deletions.
  1. +1 −1 docs/jabber
  2. +3 −4 services/jabber.rb
  3. +9 −13 test/jabber_test.rb
View
2 docs/jabber
@@ -4,7 +4,7 @@ Jabber
Install Notes
-------------
- 1. user is the Jabber ID (e.g.: myusername@jabber.org). Multiple users can be added by separating them with commas. Currently, there is a maximum of 25 users.
+ 1. user is the Jabber ID (e.g.: myusername@jabber.org). Multiple users can be added by separating them with commas.
2. muc is the Jabber ID (e.g.: talks@conference.jabber.org/Nick). Multiple conferences can be added by separating them with commas.
Developer Notes
View
7 services/jabber.rb
@@ -56,15 +56,14 @@ def deliver_messages(message, recipients)
def deliver_muc(message, conferences)
conferences.each do |conference|
- muc = mucs[conference]
- muc ||= mucs[conference] = ::Jabber::MUC::MUCClient.new(im.client)
- muc.join(conference) unless muc.active?()
+ muc = ::Jabber::MUC::MUCClient.new(im.client)
+ muc.join(conference)
im.deliver_deferred conference, message, :groupchat
end
end
def mucs
- @@mucs ||= {}
+ @mucs ||= {}
end
attr_writer :im
View
22 test/jabber_test.rb
@@ -8,7 +8,6 @@ class Client
def initialize(conference)
@conference = conference
end
- def active?() true end
end
attr_accessor :accept_subscriptions
@@ -26,9 +25,6 @@ def deliver_deferred(*args)
def test_push
svc = service({'user' => 'a,b , c , b', 'muc' => 'e,f , g, f'}, payload)
svc.im = FakeJabber.new
- svc.mucs['e'] = FakeJabber::Client.new('e')
- svc.mucs['f'] = FakeJabber::Client.new('f')
- svc.mucs['g'] = FakeJabber::Client.new('g')
svc.receive_push
assert svc.im.accept_subscriptions
@@ -45,17 +41,17 @@ def test_push
assert_equal 'c', msg[0]
assert_equal :chat, msg[2]
- #assert msg = svc.im.delivered.shift
- #assert_equal 'e', msg[0]
- #assert_equal :groupchat, msg[2]
+ assert msg = svc.im.delivered.shift
+ assert_equal 'e', msg[0]
+ assert_equal :groupchat, msg[2]
- #assert msg = svc.im.delivered.shift
- #assert_equal 'f', msg[0]
- #assert_equal :groupchat, msg[2]
+ assert msg = svc.im.delivered.shift
+ assert_equal 'f', msg[0]
+ assert_equal :groupchat, msg[2]
- #assert msg = svc.im.delivered.shift
- #assert_equal 'g', msg[0]
- #assert_equal :groupchat, msg[2]
+ assert msg = svc.im.delivered.shift
+ assert_equal 'g', msg[0]
+ assert_equal :groupchat, msg[2]
assert_nil svc.im.delivered.shift
end

0 comments on commit c320894

Please sign in to comment.
Something went wrong with that request. Please try again.