Skip to content

Commit

Permalink
force Jabber::Simple to send messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Jan 13, 2009
1 parent 0fe1263 commit 2e95078
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions services/jabber.rb
@@ -1,12 +1,23 @@
# Jabber::Simple does some insane kind of queueing if it thinks
# we are not in their buddy list (which is always) so messages
# never get sent before we disconnect. This forces the library
# to assume the recipient is a buddy.
class Jabber::Contact
def subscribed_to?(x); true; end
end

service :jabber do |data, payload|
repository = payload['repository']['name']
branch = payload['ref'].split('/').last
recipient = data['user']
im = Jabber::Simple.new(jabber_user, jabber_password)


# Ask recipient to be our buddy if need be
im.add(recipient)

# Accept any friend request
im.accept_subscriptions = true

payload['commits'].each do |commit|
sha1 = commit['id']
im.deliver recipient, <<EOM
Expand Down

0 comments on commit 2e95078

Please sign in to comment.