aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/notifier.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-06-09 18:09:52 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-06-09 18:09:52 +0100
commit495c44445642cfae8f23fadde299ad5307f5be58 (patch)
tree0104c9eef164235aa5ab05b126c8f63e52fb8624 /lib/mauve/notifier.rb
parent0c88fcc91db1b003cd5d5311f62700c7867b4099 (diff)
Big commit
--HG-- rename : views/please_authenticate.haml => views/login.haml
Diffstat (limited to 'lib/mauve/notifier.rb')
-rw-r--r--lib/mauve/notifier.rb31
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