diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc index b140a3bdeec4..faad4b07452a 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc @@ -18,6 +18,7 @@ #include "bat/ads/internal/ads_client_helper.h" #include "bat/ads/internal/base/unittest/unittest_base.h" #include "bat/ads/internal/base/unittest/unittest_time_util.h" +#include "bat/ads/internal/catalog/catalog_util.h" #include "bat/ads/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h" #include "bat/ads/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h" #include "bat/ads/internal/creatives/new_tab_page_ads/new_tab_page_ad_builder.h" @@ -304,7 +305,7 @@ TEST_F(BatAdsNewTabPageAdEventHandlerIfAdsDisabledTest, FireAdEvents(ad_event, ads_per_day - 1); - AdvanceClockBy(base::Days(1) - base::Seconds(1)); + AdvanceClockBy(GetCatalogPing() - base::Seconds(1)); const std::string placement_id = base::GUID::GenerateRandomV4().AsLowercaseString(); @@ -331,7 +332,7 @@ TEST_F(BatAdsNewTabPageAdEventHandlerIfAdsDisabledTest, FireAdEvents(ad_event, ads_per_day); - AdvanceClockBy(base::Days(1) - base::Seconds(1)); + AdvanceClockBy(GetCatalogPing() - base::Seconds(1)); const std::string placement_id = base::GUID::GenerateRandomV4().AsLowercaseString(); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ads/serving/permission_rules/catalog_permission_rule_test.cc b/vendor/bat-native-ads/src/bat/ads/internal/ads/serving/permission_rules/catalog_permission_rule_test.cc index a40d3b402199..691d58cc4dba 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ads/serving/permission_rules/catalog_permission_rule_test.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/ads/serving/permission_rules/catalog_permission_rule_test.cc @@ -43,9 +43,9 @@ TEST_F(BatAdsCatalogPermissionRuleIntegrationTest, AllowAd) { } TEST_F(BatAdsCatalogPermissionRuleIntegrationTest, - AllowAdIfCatalogWasLastUpdated23HoursAnd59MinutesAgo) { + AllowAdIfCatalogWasLastUpdatedOnOrBeforeCatalogPing) { // Arrange - AdvanceClockBy(base::Days(1) - base::Seconds(1)); + AdvanceClockBy(GetCatalogPing() - base::Seconds(1)); // Act CatalogPermissionRule permission_rule; @@ -56,9 +56,9 @@ TEST_F(BatAdsCatalogPermissionRuleIntegrationTest, } TEST_F(BatAdsCatalogPermissionRuleIntegrationTest, - DoNotAllowAdIfCatalogWasLastUpdated1DayAgo) { + DoNotAllowAdIfCatalogWasNotUpdatedAfterCatalogPing) { // Arrange - AdvanceClockBy(base::Days(1)); + AdvanceClockBy(GetCatalogPing()); // Act CatalogPermissionRule permission_rule; diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc index adea0f03ae32..1abbaa340569 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc @@ -121,14 +121,14 @@ void Catalog::OnFetch(const mojom::UrlResponse& url_response) { return; } - SetCatalogLastUpdated(base::Time::Now()); - if (!HasCatalogChanged(catalog.id)) { BLOG(1, "Catalog id " << catalog.id << " is up to date"); FetchAfterDelay(); return; } + SetCatalogLastUpdated(base::Time::Now()); + SaveCatalog(catalog); NotifyDidUpdateCatalog(catalog); FetchAfterDelay(); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc index 7c5e464a8bf0..db821cba85cf 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc @@ -29,8 +29,6 @@ namespace ads { namespace { -constexpr base::TimeDelta kCatalogLifespan = base::Days(1); - void Delete() { database::DeleteCampaigns(); database::DeleteCreativeNotificationAds(); @@ -122,7 +120,7 @@ bool HasCatalogChanged(const std::string& catalog_id) { } bool HasCatalogExpired() { - if (base::Time::Now() < GetCatalogLastUpdated() + kCatalogLifespan) { + if (base::Time::Now() < GetCatalogLastUpdated() + GetCatalogPing()) { return false; } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util_unittest.cc index 1b75c6f25c64..c488b0903635 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util_unittest.cc @@ -87,6 +87,7 @@ TEST_F(BatAdsCatalogUtilTest, CatalogHasNotChanged) { TEST_F(BatAdsCatalogUtilTest, CatalogHasExpired) { // Arrange + SetCatalogPing(base::Days(1)); SetCatalogLastUpdated(Now()); // Act @@ -99,6 +100,7 @@ TEST_F(BatAdsCatalogUtilTest, CatalogHasExpired) { TEST_F(BatAdsCatalogUtilTest, CatalogHasNotExpired) { // Arrange + SetCatalogPing(base::Days(1)); SetCatalogLastUpdated(Now()); // Act