9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/twitter_notification.rb', line 9
def
if parent
if published? && Radiant.configured? && parent. && !self.
title_length = 138 - absolute_url.length
message_title = title.length > title_length ? (title[0..title_length-4] + "...") : title
message = "#{message_title}: #{absolute_url}"
begin
httpauth = Twitter::HTTPAuth.new(Radiant.config['twitter.username'], Radiant.config['twitter.password'])
client = Twitter::Base.new(httpauth)
status = client.update(message, :source => "radianttwitternotifier")
self.class.update_all({:twitter_id => status.id}, :id => self.id)
rescue Twitter::Error => e
logger.error "Twitter Notification failure: #{e.inspect}"
end
end
end
true
end
|