Browse Source

Improved error handling.

Martin Edenhofer 9 years ago
parent
commit
d25cd7da59

+ 3 - 2
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('', '')

+ 3 - 3
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)

+ 1 - 0
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: {}