diff --git a/browser/ui/webui/brave_rewards_ui.cc b/browser/ui/webui/brave_rewards_ui.cc index e883c1ab0758..1942792559d0 100644 --- a/browser/ui/webui/brave_rewards_ui.cc +++ b/browser/ui/webui/brave_rewards_ui.cc @@ -540,18 +540,22 @@ void RewardsDOMHandler::SaveSetting(const base::ListValue* args) { if (key == "contributionMinTime") { rewards_service_->SetPublisherMinVisitTime(std::stoull(value)); + OnContentSiteUpdated(rewards_service_); } if (key == "contributionMinVisits") { rewards_service_->SetPublisherMinVisits(std::stoul(value)); + OnContentSiteUpdated(rewards_service_); } if (key == "contributionNonVerified") { rewards_service_->SetPublisherAllowNonVerified(value == "true"); + OnContentSiteUpdated(rewards_service_); } if (key == "contributionVideos") { rewards_service_->SetPublisherAllowVideos(value == "true"); + OnContentSiteUpdated(rewards_service_); } if (key == "enabledContribute") { diff --git a/components/brave_rewards/browser/publisher_info_database.cc b/components/brave_rewards/browser/publisher_info_database.cc index a744dbb693aa..fa14eef00f38 100644 --- a/components/brave_rewards/browser/publisher_info_database.cc +++ b/components/brave_rewards/browser/publisher_info_database.cc @@ -487,6 +487,10 @@ std::string PublisherInfoDatabase::BuildClauses(int start, clauses += " AND ai.percent >= ?"; } + if (!filter.non_verified) { + clauses += " AND pi.verified = 1"; + } + for (const auto& it : filter.order_by) { clauses += " ORDER BY " + it.first; clauses += (it.second ? " ASC" : " DESC"); diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index 949b64fb18d5..6c946c4fe4c3 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -362,6 +362,7 @@ void RewardsServiceImpl::GetCurrentContributeList( filter.excluded = ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED; filter.percent = 1; + filter.non_verified = ledger_->GetPublisherAllowNonVerified(); ledger_->GetPublisherInfoList( start, diff --git a/vendor/bat-native-ledger/include/bat/ledger/publisher_info.h b/vendor/bat-native-ledger/include/bat/ledger/publisher_info.h index 4159bfff489a..98f0f019c72e 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/publisher_info.h +++ b/vendor/bat-native-ledger/include/bat/ledger/publisher_info.h @@ -66,6 +66,7 @@ LEDGER_EXPORT struct PublisherInfoFilter { std::vector> order_by; unsigned int min_duration; uint64_t reconcile_stamp; + bool non_verified; }; LEDGER_EXPORT struct ContributionInfo { diff --git a/vendor/bat-native-ledger/src/bat/ledger/ledger.cc b/vendor/bat-native-ledger/src/bat/ledger/ledger.cc index 952a3bd397bb..1bb95ebc5338 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/ledger.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/ledger.cc @@ -90,7 +90,8 @@ PublisherInfoFilter::PublisherInfoFilter() : excluded(PUBLISHER_EXCLUDE_FILTER::FILTER_DEFAULT), percent(0), min_duration(0), - reconcile_stamp(0) {} + reconcile_stamp(0), + non_verified(true) {} PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) : id(filter.id), category(filter.category), @@ -100,7 +101,8 @@ PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) : percent(filter.percent), order_by(filter.order_by), min_duration(filter.min_duration), - reconcile_stamp(filter.reconcile_stamp) {} + reconcile_stamp(filter.reconcile_stamp), + non_verified(filter.non_verified) {} PublisherInfoFilter::~PublisherInfoFilter() {} PublisherBanner::PublisherBanner() {} diff --git a/vendor/bat-native-ledger/src/bat_contribution.cc b/vendor/bat-native-ledger/src/bat_contribution.cc index ee055f9a99e1..890f0b542f50 100644 --- a/vendor/bat-native-ledger/src/bat_contribution.cc +++ b/vendor/bat-native-ledger/src/bat_contribution.cc @@ -115,7 +115,8 @@ void BatContribution::StartAutoContribute() { -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED, true, - current_reconcile_stamp); + current_reconcile_stamp, + ledger_->GetPublisherAllowNonVerified()); ledger_->GetPublisherInfoList( 0, 0, diff --git a/vendor/bat-native-ledger/src/bat_get_media.cc b/vendor/bat-native-ledger/src/bat_get_media.cc index 8951de364846..94b0da2f3d92 100644 --- a/vendor/bat-native-ledger/src/bat_get_media.cc +++ b/vendor/bat-native-ledger/src/bat_get_media.cc @@ -320,7 +320,8 @@ void BatGetMedia::onFetchFavIcon(const std::string& publisher_key, -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - currentReconcileStamp); + currentReconcileStamp, + true); ledger_->GetPublisherInfo(filter, std::bind(&BatGetMedia::onFetchFavIconDBResponse, this, _1, _2, favicon_url)); @@ -660,7 +661,8 @@ void BatGetMedia::fetchPublisherDataFromDB(uint64_t windowId, visit_data.local_year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - ledger_->GetReconcileStamp()); + ledger_->GetReconcileStamp(), + true); ledger_->GetPublisherInfo(filter, std::bind(&BatGetMedia::onFetchPublisherFromDBResponse, this, _1, _2, windowId, visit_data, providerType, publisher_key)); diff --git a/vendor/bat-native-ledger/src/bat_publishers.cc b/vendor/bat-native-ledger/src/bat_publishers.cc index ac23d4bef7fe..58efe850f978 100644 --- a/vendor/bat-native-ledger/src/bat_publishers.cc +++ b/vendor/bat-native-ledger/src/bat_publishers.cc @@ -107,7 +107,8 @@ void BatPublishers::saveVisit(const std::string& publisher_id, visit_data.local_year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - ledger_->GetReconcileStamp()); + ledger_->GetReconcileStamp(), + true); ledger::PublisherInfoCallback callbackGetPublishers = std::bind(&BatPublishers::saveVisitInternal, this, publisher_id, @@ -130,7 +131,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, true, - 0); + 0, + true); } ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( @@ -145,7 +147,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( year, excluded, true, - 0); + 0, + true); } ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( @@ -160,7 +163,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, min_duration, - 0); + 0, + true); } ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( @@ -170,7 +174,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( int year, ledger::PUBLISHER_EXCLUDE_FILTER excluded, bool min_duration, - const uint64_t& currentReconcileStamp) { + const uint64_t& currentReconcileStamp, + bool non_verified) { ledger::PublisherInfoFilter filter; filter.id = publisher_id; filter.category = category; @@ -179,6 +184,7 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter( filter.excluded = excluded; filter.min_duration = min_duration ? getPublisherMinVisitTime() : 0; filter.reconcile_stamp = currentReconcileStamp; + filter.non_verified = non_verified; return filter; } @@ -230,6 +236,12 @@ void BatPublishers::saveVisitInternal( return; } + bool verified = isVerified(publisher_id); + + if (!ledger_->GetPublisherAllowNonVerified() && !verified) { + return; + } + bool new_visit = false; if (!publisher_info.get()) { new_visit = true; @@ -257,7 +269,7 @@ void BatPublishers::saveVisitInternal( } } publisher_info->score += concaveScore(duration); - publisher_info->verified = isVerified(publisher_info->id); + publisher_info->verified = verified; publisher_info->reconcile_stamp = ledger_->GetReconcileStamp(); auto media_info = std::make_unique(*publisher_info); @@ -293,7 +305,8 @@ void BatPublishers::setExclude(const std::string& publisher_id, const ledger::PU -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - currentReconcileStamp); + currentReconcileStamp, + true); ledger_->GetPublisherInfo(filter, std::bind(&BatPublishers::onSetExcludeInternal, this, exclude, _1, _2)); } @@ -307,7 +320,8 @@ void BatPublishers::setPanelExclude(const std::string& publisher_id, -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - currentReconcileStamp); + currentReconcileStamp, + true); ledger_->GetPublisherInfo(filter, std::bind( &BatPublishers::onSetPanelExcludeInternal, this, exclude, windowId, _1, _2)); @@ -394,7 +408,8 @@ void BatPublishers::restorePublishers() { -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_EXCLUDED, false, - currentReconcileStamp); + currentReconcileStamp, + true); ledger_->GetPublisherInfoList(0, 0, filter, std::bind(&BatPublishers::onRestorePublishersInternal, this, _1, _2)); } @@ -560,7 +575,8 @@ void BatPublishers::synopsisNormalizer(const ledger::PublisherInfo& info) { info.year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED, true, - ledger_->GetReconcileStamp()); + ledger_->GetReconcileStamp(), + ledger_->GetPublisherAllowNonVerified()); // TODO SZ: We pull the whole list currently, I don't think it consumes lots of RAM, but could. // We need to limit it and iterate. ledger_->GetPublisherInfoList(0, 0, filter, std::bind(&BatPublishers::synopsisNormalizerInternal, this, @@ -788,7 +804,8 @@ void BatPublishers::getPublisherActivityFromUrl(uint64_t windowId, const ledger: visit_data.local_year, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - ledger_->GetReconcileStamp()); + ledger_->GetReconcileStamp(), + true); ledger::VisitData new_data; new_data.domain = visit_data.domain; @@ -885,7 +902,8 @@ void BatPublishers::getPublisherBanner(const std::string& publisher_id, -1, ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL, false, - currentReconcileStamp); + currentReconcileStamp, + true); ledger::PublisherInfoCallback callbackGetPublisher = std::bind(&BatPublishers::onPublisherBanner, this, diff --git a/vendor/bat-native-ledger/src/bat_publishers.h b/vendor/bat-native-ledger/src/bat_publishers.h index d49ec61f642b..0ebf8939570d 100644 --- a/vendor/bat-native-ledger/src/bat_publishers.h +++ b/vendor/bat-native-ledger/src/bat_publishers.h @@ -123,7 +123,8 @@ class BatPublishers : public ledger::LedgerCallbackHandler { int year, ledger::PUBLISHER_EXCLUDE_FILTER excluded, bool min_duration, - const uint64_t& currentReconcileStamp); + const uint64_t& currentReconcileStamp, + bool non_verified); void clearAllBalanceReports(); void NormalizeContributeWinners( diff --git a/vendor/bat-native-ledger/src/ledger_impl.cc b/vendor/bat-native-ledger/src/ledger_impl.cc index 2828691a4097..a9d4c2da90da 100644 --- a/vendor/bat-native-ledger/src/ledger_impl.cc +++ b/vendor/bat-native-ledger/src/ledger_impl.cc @@ -805,20 +805,23 @@ void LedgerImpl::OnRemovedRecurring(ledger::Result result) { } } -ledger::PublisherInfoFilter LedgerImpl::CreatePublisherFilter(const std::string& publisher_id, - ledger::PUBLISHER_CATEGORY category, - ledger::PUBLISHER_MONTH month, - int year, - ledger::PUBLISHER_EXCLUDE_FILTER excluded, - bool min_duration, - const uint64_t& currentReconcileStamp) { +ledger::PublisherInfoFilter LedgerImpl::CreatePublisherFilter( + const std::string& publisher_id, + ledger::PUBLISHER_CATEGORY category, + ledger::PUBLISHER_MONTH month, + int year, + ledger::PUBLISHER_EXCLUDE_FILTER excluded, + bool min_duration, + const uint64_t& currentReconcileStamp, + bool non_verified) { return bat_publishers_->CreatePublisherFilter(publisher_id, - category, - month, - year, - excluded, - min_duration, - currentReconcileStamp); + category, + month, + year, + excluded, + min_duration, + currentReconcileStamp, + non_verified); } diff --git a/vendor/bat-native-ledger/src/ledger_impl.h b/vendor/bat-native-ledger/src/ledger_impl.h index 71472eecbbbb..45ea827afaa6 100644 --- a/vendor/bat-native-ledger/src/ledger_impl.h +++ b/vendor/bat-native-ledger/src/ledger_impl.h @@ -187,13 +187,15 @@ class LedgerImpl : public ledger::Ledger, const uint32_t date) override; void GetRecurringDonations(ledger::PublisherInfoListCallback callback); void RemoveRecurring(const std::string& publisher_key) override; - ledger::PublisherInfoFilter CreatePublisherFilter(const std::string& publisher_id, + ledger::PublisherInfoFilter CreatePublisherFilter( + const std::string& publisher_id, ledger::PUBLISHER_CATEGORY category, ledger::PUBLISHER_MONTH month, int year, ledger::PUBLISHER_EXCLUDE_FILTER excluded, bool min_duration, - const uint64_t& currentReconcileStamp); + const uint64_t& currentReconcileStamp, + bool non_verified); std::unique_ptr Log( const char* file, int line,