Skip to content

Commit 08341f7

Browse files
committed
Adds support for non-verified flag
Resolves brave/brave-browser#2111
1 parent f5c1558 commit 08341f7

File tree

11 files changed

+72
-33
lines changed

11 files changed

+72
-33
lines changed

browser/ui/webui/brave_rewards_ui.cc

+4
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,22 @@ void RewardsDOMHandler::SaveSetting(const base::ListValue* args) {
540540

541541
if (key == "contributionMinTime") {
542542
rewards_service_->SetPublisherMinVisitTime(std::stoull(value));
543+
OnContentSiteUpdated(rewards_service_);
543544
}
544545

545546
if (key == "contributionMinVisits") {
546547
rewards_service_->SetPublisherMinVisits(std::stoul(value));
548+
OnContentSiteUpdated(rewards_service_);
547549
}
548550

549551
if (key == "contributionNonVerified") {
550552
rewards_service_->SetPublisherAllowNonVerified(value == "true");
553+
OnContentSiteUpdated(rewards_service_);
551554
}
552555

553556
if (key == "contributionVideos") {
554557
rewards_service_->SetPublisherAllowVideos(value == "true");
558+
OnContentSiteUpdated(rewards_service_);
555559
}
556560

557561
if (key == "enabledContribute") {

components/brave_rewards/browser/publisher_info_database.cc

+4
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ std::string PublisherInfoDatabase::BuildClauses(int start,
487487
clauses += " AND ai.percent >= ?";
488488
}
489489

490+
if (!filter.non_verified) {
491+
clauses += " AND pi.verified = 1";
492+
}
493+
490494
for (const auto& it : filter.order_by) {
491495
clauses += " ORDER BY " + it.first;
492496
clauses += (it.second ? " ASC" : " DESC");

components/brave_rewards/browser/rewards_service_impl.cc

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ void RewardsServiceImpl::GetCurrentContributeList(
362362
filter.excluded =
363363
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED;
364364
filter.percent = 1;
365+
filter.non_verified = ledger_->GetPublisherAllowNonVerified();
365366

366367
ledger_->GetPublisherInfoList(
367368
start,

vendor/bat-native-ledger/include/bat/ledger/publisher_info.h

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ LEDGER_EXPORT struct PublisherInfoFilter {
6666
std::vector<std::pair<std::string, bool>> order_by;
6767
unsigned int min_duration;
6868
uint64_t reconcile_stamp;
69+
bool non_verified;
6970
};
7071

7172
LEDGER_EXPORT struct ContributionInfo {

vendor/bat-native-ledger/src/bat/ledger/ledger.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ PublisherInfoFilter::PublisherInfoFilter() :
9090
excluded(PUBLISHER_EXCLUDE_FILTER::FILTER_DEFAULT),
9191
percent(0),
9292
min_duration(0),
93-
reconcile_stamp(0) {}
93+
reconcile_stamp(0),
94+
non_verified(true) {}
9495
PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) :
9596
id(filter.id),
9697
category(filter.category),
@@ -100,7 +101,8 @@ PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) :
100101
percent(filter.percent),
101102
order_by(filter.order_by),
102103
min_duration(filter.min_duration),
103-
reconcile_stamp(filter.reconcile_stamp) {}
104+
reconcile_stamp(filter.reconcile_stamp),
105+
non_verified(filter.non_verified) {}
104106
PublisherInfoFilter::~PublisherInfoFilter() {}
105107

106108
PublisherBanner::PublisherBanner() {}

vendor/bat-native-ledger/src/bat_contribution.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ void BatContribution::StartAutoContribute() {
115115
-1,
116116
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED,
117117
true,
118-
current_reconcile_stamp);
118+
current_reconcile_stamp,
119+
ledger_->GetPublisherAllowNonVerified());
119120
ledger_->GetPublisherInfoList(
120121
0,
121122
0,

vendor/bat-native-ledger/src/bat_get_media.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ void BatGetMedia::onFetchFavIcon(const std::string& publisher_key,
320320
-1,
321321
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
322322
false,
323-
currentReconcileStamp);
323+
currentReconcileStamp,
324+
true);
324325
ledger_->GetPublisherInfo(filter,
325326
std::bind(&BatGetMedia::onFetchFavIconDBResponse,
326327
this, _1, _2, favicon_url));
@@ -660,7 +661,8 @@ void BatGetMedia::fetchPublisherDataFromDB(uint64_t windowId,
660661
visit_data.local_year,
661662
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
662663
false,
663-
ledger_->GetReconcileStamp());
664+
ledger_->GetReconcileStamp(),
665+
true);
664666
ledger_->GetPublisherInfo(filter,
665667
std::bind(&BatGetMedia::onFetchPublisherFromDBResponse,
666668
this, _1, _2, windowId, visit_data, providerType, publisher_key));

vendor/bat-native-ledger/src/bat_publishers.cc

+30-12
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ void BatPublishers::saveVisit(const std::string& publisher_id,
107107
visit_data.local_year,
108108
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
109109
false,
110-
ledger_->GetReconcileStamp());
110+
ledger_->GetReconcileStamp(),
111+
true);
111112

112113
ledger::PublisherInfoCallback callbackGetPublishers = std::bind(&BatPublishers::saveVisitInternal, this,
113114
publisher_id,
@@ -130,7 +131,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
130131
year,
131132
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
132133
true,
133-
0);
134+
0,
135+
true);
134136
}
135137

136138
ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
@@ -145,7 +147,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
145147
year,
146148
excluded,
147149
true,
148-
0);
150+
0,
151+
true);
149152
}
150153

151154
ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
@@ -160,7 +163,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
160163
year,
161164
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
162165
min_duration,
163-
0);
166+
0,
167+
true);
164168
}
165169

166170
ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
@@ -170,7 +174,8 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
170174
int year,
171175
ledger::PUBLISHER_EXCLUDE_FILTER excluded,
172176
bool min_duration,
173-
const uint64_t& currentReconcileStamp) {
177+
const uint64_t& currentReconcileStamp,
178+
bool non_verified) {
174179
ledger::PublisherInfoFilter filter;
175180
filter.id = publisher_id;
176181
filter.category = category;
@@ -179,6 +184,7 @@ ledger::PublisherInfoFilter BatPublishers::CreatePublisherFilter(
179184
filter.excluded = excluded;
180185
filter.min_duration = min_duration ? getPublisherMinVisitTime() : 0;
181186
filter.reconcile_stamp = currentReconcileStamp;
187+
filter.non_verified = non_verified;
182188

183189
return filter;
184190
}
@@ -230,6 +236,12 @@ void BatPublishers::saveVisitInternal(
230236
return;
231237
}
232238

239+
bool verified = isVerified(publisher_id);
240+
241+
if (!ledger_->GetPublisherAllowNonVerified() && !verified) {
242+
return;
243+
}
244+
233245
bool new_visit = false;
234246
if (!publisher_info.get()) {
235247
new_visit = true;
@@ -257,7 +269,7 @@ void BatPublishers::saveVisitInternal(
257269
}
258270
}
259271
publisher_info->score += concaveScore(duration);
260-
publisher_info->verified = isVerified(publisher_info->id);
272+
publisher_info->verified = verified;
261273
publisher_info->reconcile_stamp = ledger_->GetReconcileStamp();
262274

263275
auto media_info = std::make_unique<ledger::PublisherInfo>(*publisher_info);
@@ -293,7 +305,8 @@ void BatPublishers::setExclude(const std::string& publisher_id, const ledger::PU
293305
-1,
294306
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
295307
false,
296-
currentReconcileStamp);
308+
currentReconcileStamp,
309+
true);
297310
ledger_->GetPublisherInfo(filter, std::bind(&BatPublishers::onSetExcludeInternal,
298311
this, exclude, _1, _2));
299312
}
@@ -307,7 +320,8 @@ void BatPublishers::setPanelExclude(const std::string& publisher_id,
307320
-1,
308321
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
309322
false,
310-
currentReconcileStamp);
323+
currentReconcileStamp,
324+
true);
311325
ledger_->GetPublisherInfo(filter, std::bind(
312326
&BatPublishers::onSetPanelExcludeInternal,
313327
this, exclude, windowId, _1, _2));
@@ -394,7 +408,8 @@ void BatPublishers::restorePublishers() {
394408
-1,
395409
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_EXCLUDED,
396410
false,
397-
currentReconcileStamp);
411+
currentReconcileStamp,
412+
true);
398413
ledger_->GetPublisherInfoList(0, 0, filter, std::bind(&BatPublishers::onRestorePublishersInternal,
399414
this, _1, _2));
400415
}
@@ -560,7 +575,8 @@ void BatPublishers::synopsisNormalizer(const ledger::PublisherInfo& info) {
560575
info.year,
561576
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED,
562577
true,
563-
ledger_->GetReconcileStamp());
578+
ledger_->GetReconcileStamp(),
579+
ledger_->GetPublisherAllowNonVerified());
564580
// TODO SZ: We pull the whole list currently, I don't think it consumes lots of RAM, but could.
565581
// We need to limit it and iterate.
566582
ledger_->GetPublisherInfoList(0, 0, filter, std::bind(&BatPublishers::synopsisNormalizerInternal, this,
@@ -788,7 +804,8 @@ void BatPublishers::getPublisherActivityFromUrl(uint64_t windowId, const ledger:
788804
visit_data.local_year,
789805
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
790806
false,
791-
ledger_->GetReconcileStamp());
807+
ledger_->GetReconcileStamp(),
808+
true);
792809

793810
ledger::VisitData new_data;
794811
new_data.domain = visit_data.domain;
@@ -885,7 +902,8 @@ void BatPublishers::getPublisherBanner(const std::string& publisher_id,
885902
-1,
886903
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL,
887904
false,
888-
currentReconcileStamp);
905+
currentReconcileStamp,
906+
true);
889907

890908
ledger::PublisherInfoCallback callbackGetPublisher = std::bind(&BatPublishers::onPublisherBanner,
891909
this,

vendor/bat-native-ledger/src/bat_publishers.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ class BatPublishers : public ledger::LedgerCallbackHandler {
123123
int year,
124124
ledger::PUBLISHER_EXCLUDE_FILTER excluded,
125125
bool min_duration,
126-
const uint64_t& currentReconcileStamp);
126+
const uint64_t& currentReconcileStamp,
127+
bool non_verified);
127128

128129
void clearAllBalanceReports();
129130
void NormalizeContributeWinners(

vendor/bat-native-ledger/src/ledger_impl.cc

+16-13
Original file line numberDiff line numberDiff line change
@@ -805,20 +805,23 @@ void LedgerImpl::OnRemovedRecurring(ledger::Result result) {
805805
}
806806
}
807807

808-
ledger::PublisherInfoFilter LedgerImpl::CreatePublisherFilter(const std::string& publisher_id,
809-
ledger::PUBLISHER_CATEGORY category,
810-
ledger::PUBLISHER_MONTH month,
811-
int year,
812-
ledger::PUBLISHER_EXCLUDE_FILTER excluded,
813-
bool min_duration,
814-
const uint64_t& currentReconcileStamp) {
808+
ledger::PublisherInfoFilter LedgerImpl::CreatePublisherFilter(
809+
const std::string& publisher_id,
810+
ledger::PUBLISHER_CATEGORY category,
811+
ledger::PUBLISHER_MONTH month,
812+
int year,
813+
ledger::PUBLISHER_EXCLUDE_FILTER excluded,
814+
bool min_duration,
815+
const uint64_t& currentReconcileStamp,
816+
bool non_verified) {
815817
return bat_publishers_->CreatePublisherFilter(publisher_id,
816-
category,
817-
month,
818-
year,
819-
excluded,
820-
min_duration,
821-
currentReconcileStamp);
818+
category,
819+
month,
820+
year,
821+
excluded,
822+
min_duration,
823+
currentReconcileStamp,
824+
non_verified);
822825
}
823826

824827

vendor/bat-native-ledger/src/ledger_impl.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@ class LedgerImpl : public ledger::Ledger,
187187
const uint32_t date) override;
188188
void GetRecurringDonations(ledger::PublisherInfoListCallback callback);
189189
void RemoveRecurring(const std::string& publisher_key) override;
190-
ledger::PublisherInfoFilter CreatePublisherFilter(const std::string& publisher_id,
190+
ledger::PublisherInfoFilter CreatePublisherFilter(
191+
const std::string& publisher_id,
191192
ledger::PUBLISHER_CATEGORY category,
192193
ledger::PUBLISHER_MONTH month,
193194
int year,
194195
ledger::PUBLISHER_EXCLUDE_FILTER excluded,
195196
bool min_duration,
196-
const uint64_t& currentReconcileStamp);
197+
const uint64_t& currentReconcileStamp,
198+
bool non_verified);
197199
std::unique_ptr<ledger::LogStream> Log(
198200
const char* file,
199201
int line,

0 commit comments

Comments
 (0)