Improved error handling.

This commit is contained in:
Martin Edenhofer 2016-02-11 02:10:23 +01:00
parent f1d78ade51
commit 100cca46d0

View file

@ -266,6 +266,10 @@ returns
return if !@sync[:search] return if !@sync[:search]
return if @sync[:search].empty? return if @sync[:search].empty?
@sync[:search].each { |search| @sync[:search].each { |search|
next if !search[:term]
next if search[:term].to_s.empty?
next if !search[:group_id]
next if search[:group_id].to_s.empty?
result_type = search[:type] || 'mixed' result_type = search[:type] || 'mixed'
Rails.logger.debug " - searching for '#{search[:term]}'" Rails.logger.debug " - searching for '#{search[:term]}'"
@rest_client.client.search(search[:term], result_type: result_type).collect { |tweet| @rest_client.client.search(search[:term], result_type: result_type).collect { |tweet|
@ -279,6 +283,8 @@ returns
def fetch_mentions def fetch_mentions
return if !@sync[:mentions] return if !@sync[:mentions]
return if @sync[:mentions].empty? return if @sync[:mentions].empty?
return if !@sync[:mentions][:group_id]
return if @sync[:mentions][:group_id].to_s.empty?
Rails.logger.debug ' - searching for mentions' Rails.logger.debug ' - searching for mentions'
@rest_client.client.mentions_timeline.each { |tweet| @rest_client.client.mentions_timeline.each { |tweet|
next if Ticket::Article.find_by(message_id: tweet.id) next if Ticket::Article.find_by(message_id: tweet.id)
@ -290,6 +296,8 @@ returns
def fetch_direct_messages def fetch_direct_messages
return if !@sync[:direct_messages] return if !@sync[:direct_messages]
return if @sync[:direct_messages].empty? return if @sync[:direct_messages].empty?
return if !@sync[:direct_messages][:group_id]
return if @sync[:direct_messages][:group_id].to_s.empty?
Rails.logger.debug ' - searching for direct_messages' Rails.logger.debug ' - searching for direct_messages'
@rest_client.client.direct_messages.each { |tweet| @rest_client.client.direct_messages.each { |tweet|
next if Ticket::Article.find_by(message_id: tweet.id) next if Ticket::Article.find_by(message_id: tweet.id)