-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reddit users can now receive direct contributions (tips) via Brave Rewards panel #2624
Conversation
6be111d
to
9be02c0
Compare
9be02c0
to
208ae86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bascially LGTM, just a few comments.
test/BUILD.gn
Outdated
@@ -118,6 +118,7 @@ test("brave_unit_tests") { | |||
if (brave_rewards_enabled) { | |||
sources += [ | |||
"//brave/vendor/bat-native-ledger/src/bat/ledger/internal/media/helper_unittest.cc", | |||
"//brave/vendor/bat-native-ledger/src/bat/ledger/internal/media/reddit_unittest.cc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Sometimes hard to tell in a diff, but looks like extra spacing at the beginning of this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was. Removed.
// Canonicalize away 'old.reddit.com' and replace with 'www.reddit.com'. | ||
std::string new_host = reddit_url.host().substr( | ||
0, reddit_url.host().length()); | ||
new_host.replace(new_host.find("old"), 3, "www"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to call find
here? Seems like it would always return 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not. Removed.
GURL reddit_url(url); | ||
if (reddit_url.DomainIs(OLD_REDDIT_DOMAIN)) { | ||
// Canonicalize away 'old.reddit.com' and replace with 'www.reddit.com'. | ||
std::string new_host = reddit_url.host().substr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just do a direct assignment here?
std::string new_host = reddit_url.host();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Thanks for the catches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
std::string url = REDDIT_TLD; | ||
std::string name = REDDIT_MEDIA_TYPE; | ||
|
||
if (!url.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: switch if and return, so that we don't have this big if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
void MediaReddit::OnMediaActivityError( | ||
const ledger::VisitData& visit_data, | ||
uint64_t window_id) { | ||
std::string url = REDDIT_TLD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const ledger::VisitData& visit_data, | ||
uint64_t window_id) { | ||
std::string url = REDDIT_TLD; | ||
std::string name = REDDIT_MEDIA_TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
void MediaReddit::UserPath( | ||
uint64_t window_id, | ||
const ledger::VisitData& visit_data) { | ||
std::string user = GetUserNameFromUrl(visit_data.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return; | ||
} | ||
|
||
std::string media_key = (std::string)REDDIT_MEDIA_TYPE + "_" + user; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return std::string(); | ||
} | ||
|
||
std::vector<std::string> parts = base::SplitString( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
uint64_t window_id, | ||
const ledger::VisitData& visit_data, | ||
const std::string& publisher_key) { | ||
auto filter = ledger_->CreateActivityFilter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
208ae86
to
164f16b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
164f16b
to
7c46c4c
Compare
Updated with merged |
7c46c4c
to
e3006e9
Compare
e3006e9
to
47b456a
Compare
Removed package-lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jenkins pipeline for building PRs on Linux
Fixes brave/brave-browser#4745
Brave-UI: brave/brave-ui#495
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests && npm run test-security
) onnpm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
old.reddit.com
Repeat all steps above for unverified publishers and ensure panel shows correctly (e. g. standard reddit icon, etc)
Reviewer Checklist:
After-merge Checklist:
changes has landed on.