diff --git a/app/controllers/admin/statuses_controller.rb b/app/controllers/admin/statuses_controller.rb index 6dc2725582..f41a4a3ca5 100644 --- a/app/controllers/admin/statuses_controller.rb +++ b/app/controllers/admin/statuses_controller.rb @@ -49,8 +49,13 @@ def new_or_edit end if @status.save - @status.send_to_twitter(current_user) if params[:status][:push_to_twitter] and @status.twitter_id.nil? or @status.twitter_id.empty? flash[:notice] = _("Status was successfully %s.", message) + if params[:status][:push_to_twitter] and @status.twitter_id.nil? or @status.twitter_id.empty? + unless @status.send_to_twitter(current_user) + flash[:error] = _("Oooops something wrong happened") + flash[:notice] = nil + end + end redirect_to :action => 'new' end return diff --git a/app/models/status.rb b/app/models/status.rb index 613f62158a..97974b48f1 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -64,16 +64,15 @@ def send_to_twitter(user) message = "#{message}#{short_permalink}" end - puts message - begin tweet = twitter.update(message) self.twitter_id = tweet.attrs[:id_str] self.save user.update_twitter_profile_image(tweet.attrs[:user][:profile_image_url]) + return true rescue - flash[:error] = "Oooops something wrong happened" + return false end end