From d25cd7da59c45cfc7b56ddd91472a87e9ada278a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 2 Jan 2016 17:10:12 +0100 Subject: [PATCH] Improved error handling. --- .../javascripts/app/controllers/_channel/twitter.coffee | 5 +++-- app/models/channel/driver/twitter.rb | 6 +++--- lib/external_credential/twitter.rb | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/twitter.coffee b/app/assets/javascripts/app/controllers/_channel/twitter.coffee index 33478f7c1..7ef166c88 100644 --- a/app/assets/javascripts/app/controllers/_channel/twitter.coffee +++ b/app/assets/javascripts/app/controllers/_channel/twitter.coffee @@ -141,8 +141,9 @@ class Index extends App.ControllerContent groupSelection(group_id, placeholder, 'search') content.find('.js-searchTermList').append(placeholder) - for item in channel.options.sync.search - placeholderAdd(item.term, item.group_id, 'search') + if channel.options && channel.options.sync && channel.options.sync.search + for item in channel.options.sync.search + placeholderAdd(item.term, item.group_id, 'search') content.find('.js-searchTermAdd').on('click', -> placeholderAdd('', '') diff --git a/app/models/channel/driver/twitter.rb b/app/models/channel/driver/twitter.rb index 6abc5e4c9..db83a32cf 100644 --- a/app/models/channel/driver/twitter.rb +++ b/app/models/channel/driver/twitter.rb @@ -121,7 +121,7 @@ class Channel::Driver::Twitter counter = 0 @tweet.client.search(search[:term], result_type: result_type).collect { |tweet| - break if search[:limit] && search[:limit] <= counter + break if @sync[:limit] && @sync[:limit] <= counter break if Ticket::Article.find_by(message_id: tweet.id) @tweet.to_group(tweet, search[:group_id], @channel) @@ -141,7 +141,7 @@ class Channel::Driver::Twitter counter = 0 @tweet.client.mentions_timeline.each { |tweet| - break if @sync[:mentions][:limit] && @sync[:mentions][:limit] <= counter + break if @sync[:limit] && @sync[:limit] <= counter break if Ticket::Article.find_by(message_id: tweet.id) @tweet.to_group(tweet, @sync[:mentions][:group_id], @channel) @@ -160,7 +160,7 @@ class Channel::Driver::Twitter counter = 0 @tweet.client.direct_messages.each { |tweet| - break if @sync[:direct_messages][:limit] && @sync[:direct_messages][:limit] <= counter + break if @sync[:limit] && @sync[:limit] <= counter break if Ticket::Article.find_by(message_id: tweet.id) @tweet.to_group(tweet, @sync[:direct_messages][:group_id], @channel) diff --git a/lib/external_credential/twitter.rb b/lib/external_credential/twitter.rb index 4f9968e8d..77831a94f 100644 --- a/lib/external_credential/twitter.rb +++ b/lib/external_credential/twitter.rb @@ -69,6 +69,7 @@ class ExternalCredential::Twitter oauth_token_secret: access_token.secret, }, sync: { + limit: 20, search: [], mentions: {}, direct_messages: {}