Handle new page rate limit.

This commit is contained in:
Martin Edenhofer 2016-07-18 09:37:43 +02:00
parent 39479171a7
commit 3b377bc04b
2 changed files with 10 additions and 4 deletions

View file

@ -43,6 +43,13 @@ class Channel::Driver::Facebook
=end
def fetchable?(_channel)
return true if Rails.env.test?
# because of new page rate limit - https://developers.facebook.com/blog/post/2016/06/16/page-level-rate-limits/
# only fetch once in 5 minutes
return true if !channel.preferences
return true if !channel.preferences[:last_fetch]
return false if channel.preferences[:last_fetch] > Time.zone.now - 5.minutes
true
end

View file

@ -175,8 +175,7 @@ class FacebookTest < ActiveSupport::TestCase
# check customer
customer = ticket.customer
assert_equal('Bernd', customer.firstname)
assert_equal('Hofbecker', customer.lastname)
assert_equal(customer_name, "#{customer.firstname} #{customer.lastname}")
# reply via ticket
reply_text = "What's your issue Bernd?"
@ -195,7 +194,7 @@ class FacebookTest < ActiveSupport::TestCase
outbound_article = Ticket::Article.find(outbound_article.id)
assert(outbound_article, 'outbound article created')
assert_equal(outbound_article.from, 'Hansi Merkurs Hutfabrik', 'ticket article outbound count')
assert_equal(outbound_article.from, page_name, 'ticket article outbound count')
assert_equal(outbound_article.ticket.articles.count, 2, 'ticket article outbound count')
post_comment = 'The peacock feather is fallen off.'
@ -226,7 +225,7 @@ class FacebookTest < ActiveSupport::TestCase
outbound_article = Ticket::Article.find(outbound_article.id)
assert(outbound_article, 'outbound article created')
assert_equal(outbound_article.from, 'Hansi Merkurs Hutfabrik', 'ticket article outbound count')
assert_equal(outbound_article.from, page_name, 'ticket article outbound count')
assert_equal(outbound_article.ticket.articles.count, 4, 'ticket article outbound count')
end