diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index f1b5f08c0..0876ba4f8 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -44,24 +44,24 @@ Example: { "item":"#otrs", "type": "mixed", # optional, possible 'mixed' (default), 'recent', 'popular' - "group": "OTRS", + "group_id:": 1, "limit": 1, # optional }, { "item":"#zombie23", - "group": "Zombie Apocalypse Early Warning System", + "group_id:": 2, }, { "item":"#otterhub", - "group": "Community", + "group_id:": 3, } ], "mentions" { - "group": "Twitter", + "group_id:": 4, "limit": 100, # optional }, "direct_messages": { - "group": "Twitter", + "group_id:": 4, "limit": 1, # optional } } diff --git a/app/models/channel/twitter.rb b/app/models/channel/twitter.rb index 43ebda8e4..548c49032 100644 --- a/app/models/channel/twitter.rb +++ b/app/models/channel/twitter.rb @@ -8,7 +8,7 @@ class Channel::Twitter @tweet = Tweet.new( @channel[:options][:auth] ) @sync = @channel[:options][:sync] - Rails.logger.debug "twitter fetch started" + Rails.logger.debug 'twitter fetch started' fetch_search fetch_mentions @@ -55,7 +55,7 @@ class Channel::Twitter break if search[:limit] && search[:limit] <= counter break if Ticket::Article.find_by( message_id: tweet.id.to_s ) - @tweet.to_group( tweet, search[:group] ) + @tweet.to_group( tweet, search[:group_id] ) counter += 1 } @@ -75,7 +75,7 @@ class Channel::Twitter break if @sync[:mentions][:limit] && @sync[:mentions][:limit] <= counter break if Ticket::Article.find_by( message_id: tweet.id.to_s ) - @tweet.to_group( tweet, @sync[:mentions][:group] ) + @tweet.to_group( tweet, @sync[:mentions][:group_id] ) counter += 1 } @@ -94,7 +94,7 @@ class Channel::Twitter break if @sync[:direct_messages][:limit] && @sync[:direct_messages][:limit] <= counter break if Ticket::Article.find_by( message_id: tweet.id.to_s ) - @tweet.to_group( tweet, @sync[:direct_messages][:group] ) + @tweet.to_group( tweet, @sync[:direct_messages][:group_id] ) counter += 1 } diff --git a/lib/tweet.rb b/lib/tweet.rb index b18d6fb86..44c19a07c 100644 --- a/lib/tweet.rb +++ b/lib/tweet.rb @@ -90,12 +90,12 @@ class Tweet user end - def to_ticket(tweet, user, group) + def to_ticket(tweet, user, group_id) Rails.logger.debug "Create ticket from tweet..." Rails.logger.debug tweet.inspect Rails.logger.debug user.inspect - Rails.logger.debug group.inspect + Rails.logger.debug group_id.inspect if tweet.class.to_s == 'Twitter::DirectMessage' ticket = Ticket.find_by( @@ -112,7 +112,7 @@ class Tweet Ticket.create( customer_id: user.id, title: "#{tweet.text[0, 37]}...", - group: Group.find_by( name: group ), + group_id: group_id, state: Ticket::State.find_by( name: 'new' ), priority: Ticket::Priority.find_by( name: '2 normal' ), ) @@ -154,7 +154,7 @@ class Tweet ) end - def to_group(tweet, group) + def to_group(tweet, group_id) Rails.logger.debug 'import tweet' @@ -178,10 +178,10 @@ class Tweet Rails.logger.debug 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s parent_tweet = @client.status( tweet.in_reply_to_status_id ) - ticket = to_group( parent_tweet, group ) + ticket = to_group( parent_tweet, group_id ) end else - ticket = to_ticket(tweet, user, group) + ticket = to_ticket(tweet, user, group_id) end to_article(tweet, user, ticket) diff --git a/test/integration/twitter_test.rb b/test/integration/twitter_test.rb index b369cbaf1..4e82d674c 100644 --- a/test/integration/twitter_test.rb +++ b/test/integration/twitter_test.rb @@ -45,18 +45,18 @@ class TwitterTest < ActiveSupport::TestCase search: [ { term: '#citheo42', - group: 'Twitter', + group_id: 2, }, { term: '#citheo24', - group: 'Users', + group_id: 1, }, ], mentions: { - group: 'Twitter', + group_id: 2, }, direct_messages: { - group: 'Twitter', + group_id: 2, } } }, @@ -73,7 +73,7 @@ class TwitterTest < ActiveSupport::TestCase ticket = Ticket.create( title: text[0, 40], customer_id: user.id, - group: Group.find_by( name: 'Twitter' ), + group_id: 2, state: Ticket::State.find_by( name: 'new' ), priority: Ticket::Priority.find_by( name: '2 normal' ), updated_by_id: 1,