Handle new page rate limit.
This commit is contained in:
parent
39479171a7
commit
3b377bc04b
2 changed files with 10 additions and 4 deletions
|
@ -43,6 +43,13 @@ class Channel::Driver::Facebook
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def fetchable?(_channel)
|
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
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,7 @@ class FacebookTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# check customer
|
# check customer
|
||||||
customer = ticket.customer
|
customer = ticket.customer
|
||||||
assert_equal('Bernd', customer.firstname)
|
assert_equal(customer_name, "#{customer.firstname} #{customer.lastname}")
|
||||||
assert_equal('Hofbecker', customer.lastname)
|
|
||||||
|
|
||||||
# reply via ticket
|
# reply via ticket
|
||||||
reply_text = "What's your issue Bernd?"
|
reply_text = "What's your issue Bernd?"
|
||||||
|
@ -195,7 +194,7 @@ class FacebookTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
outbound_article = Ticket::Article.find(outbound_article.id)
|
outbound_article = Ticket::Article.find(outbound_article.id)
|
||||||
assert(outbound_article, 'outbound article created')
|
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')
|
assert_equal(outbound_article.ticket.articles.count, 2, 'ticket article outbound count')
|
||||||
|
|
||||||
post_comment = 'The peacock feather is fallen off.'
|
post_comment = 'The peacock feather is fallen off.'
|
||||||
|
@ -226,7 +225,7 @@ class FacebookTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
outbound_article = Ticket::Article.find(outbound_article.id)
|
outbound_article = Ticket::Article.find(outbound_article.id)
|
||||||
assert(outbound_article, 'outbound article created')
|
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')
|
assert_equal(outbound_article.ticket.articles.count, 4, 'ticket article outbound count')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue