diff options
Diffstat (limited to 'lib/mauve/notifier.rb')
-rw-r--r-- | lib/mauve/notifier.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb index e0692f6..0127b6b 100644 --- a/lib/mauve/notifier.rb +++ b/lib/mauve/notifier.rb @@ -40,11 +40,38 @@ module Mauve def start super - Configuration.current.notification_methods['xmpp'].connect if Configuration.current.notification_methods['xmpp'] + if Configuration.current.notification_methods['xmpp'] + # + # Connect to XMPP server + # + xmpp = Configuration.current.notification_methods['xmpp'] + xmpp.connect + + Configuration.current.people.each do |username, person| + # + # Ignore people without XMPP stanzas. + # + next unless person.xmpp + + # + # For each JID, either ensure they're on our roster, or that we're in + # that chat room. + # + jid = if xmpp.is_muc?(person.xmpp) + xmpp.join_muc(person.xmpp) + else + xmpp.ensure_roster_and_subscription!(person.xmpp) + end + + Configuration.current.people[username].xmpp = jid unless jid.nil? + end + end end def stop - Configuration.current.notification_methods['xmpp'].close + if Configuration.current.notification_methods['xmpp'] + Configuration.current.notification_methods['xmpp'].close + end super end |