Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (51 sloc) 1.584 kB
class Service::Yammer < Service
string :group_id, :consumer_key, :consumer_secret,
:access_token, :access_secret
boolean :digest
white_list :group_id
def receive_push
statuses = [ ]
repository = payload['repository']['name']
if data['digest'] == '1'
commit = payload['commits'][-1]
tiny_url = shorten_url("#{payload['repository']['url']}/commits/#{ref_name}")
statuses << "#{commit['author']['name']} pushed #{payload['commits'].length}. #{tiny_url} \##{repository}"
else
payload['commits'].each do |commit|
tiny_url = shorten_url(commit['url'])
statuses << "#{commit['message']} (committer: #{commit['author']['name']}) #{tiny_url} \##{repository}"
end
end
statuses.each do |status|
params = { :body => status }
params['group_id'] = data['group_id'] unless data['group_id'].to_s.empty?
begin
send_message params
rescue
if $!.to_s =~ /authentication failed/i
raise_config_error "Invalid username or password"
else
raise
end
end
end
end
def send_message(params)
yammer.message(:post, params)
rescue RuntimeError => boom
if boom.to_s =~ /Bad Request/i
raise_config_error boom.to_s
else
raise
end
end
def yammer
@yammer ||= ::Yammer::Client.new \
:consumer => {
:key => data['consumer_key'],
:secret => data['consumer_secret']},
:access => {
:token => data['access_token'],
:secret => data['access_secret']}
end
end
Jump to Line
Something went wrong with that request. Please try again.