Skip to content
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

Show verified publishers in Rewards panel for new Twitter #3029

Merged
merged 6 commits into from
Jul 31, 2019

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Jul 26, 2019

Fix brave/brave-browser#5388

Submitter Checklist:

Test Plan:

  1. Open brave
  2. Enable rewards
  3. Open verified pubs in new tab
  4. Open BR panel
  5. Verified pubs info is not displayed in BR panel

Must test this for three scenarios:

  1. While logged into old Twitter
  2. While logged into new Twitter
  3. While not logged in at all, and just looking directly at a user page like http://twitter.com/emerick

Also, for the various scenarios, please use a clean profile as the data can be cached and lead you into thinking it's working when it's not.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@emerick emerick self-assigned this Jul 26, 2019
@NejcZdovc NejcZdovc force-pushed the new-twitter-verified-pubs branch from 3ec6324 to 34d2c67 Compare July 26, 2019 16:49
@emerick emerick marked this pull request as ready for review July 27, 2019 00:27
@emerick emerick requested a review from NejcZdovc July 27, 2019 00:27
@emerick emerick force-pushed the new-twitter-verified-pubs branch from ef0b25e to 4ad0e47 Compare July 27, 2019 11:06
@emerick emerick force-pushed the new-twitter-verified-pubs branch from ceb947e to 3c80742 Compare July 30, 2019 14:38
@emerick emerick force-pushed the new-twitter-verified-pubs branch from c2f724b to 708381c Compare July 30, 2019 18:27
@diracdeltas
Copy link
Member

other than #3029 (comment), lgtm

@emerick emerick force-pushed the new-twitter-verified-pubs branch from 708381c to bab104b Compare July 30, 2019 18:45
@NejcZdovc NejcZdovc requested a review from petemill July 30, 2019 18:46
@emerick emerick force-pushed the new-twitter-verified-pubs branch from bab104b to f405b7b Compare July 30, 2019 18:52
@petemill
Copy link
Member

I’m a little confused. It does work in my testing, but I’m trying to understand why the change is needed. Primarily, I'm worried about requesting the user details via the twitter API as soon as the page starts loading. Could this happen before the page makes any authenticated API requests, leaving our request with no auth headers yet? I'm not sure I saw that happening in my testing, but wondering if it's possible.

In general, I'm finding it difficult to follow the path of data through the code between content-script / background script and API. When a user visits the page twitter.com/user(/status/tweet), doesn’t the c++ backend interpret the URL and extract the username, regardless of 'new' or 'old' twitter. Can't that be fed to the rewards backend (for attention attribution) and, later, the panel (for display), without the content script having to look it up? Also (or similarly?) why do we provide the url in a different format for 'new' twitter (.../intent/...)?

@emerick
Copy link
Contributor Author

emerick commented Jul 30, 2019

@petemill The main problem is that the C++ backend scrapes the DOM for the Twitter user ID, but that ID is no longer present in the new Twitter redesign. In order to work around that, we request the user ID from the Twitter API and then send it to the backend. In order to avoid adding a new parameter to our APIs for the user ID (and then threading that through Mojo), @NejcZdovc suggested to just pass a different URL that already contains everything we need for the backend parsing when dealing with a "new Twitter" profile.

As far as the possibility of sending a request with no auth headers, I had the same concern. It doesn't seem to happen in practice, but it doesn't mean it's not possible. I'm definitely open to other suggestions!

@petemill
Copy link
Member

@emerick oh ok if it was already decided to do it this way instead of adding an explicit API. Thanks for the explanation @emerick. I think it would help us in the future if we add a code comment to explain exactly the above: that for old twitter, the backend parses the DOM itself, but for new twitter we fetch the userId ourselves and add it to a fake URL so the backend has everything it needs. And @NejcZdovc perhaps create an issue to modify the API to expect a specific data object where one of the properties is the userId instead of putting it in a fake Url?

@emerick
Copy link
Contributor Author

emerick commented Jul 30, 2019

@petemill Just to be totally clear, that isn't a fake URL. It's just an alternate URL that Twitter provides to a profile-like page (with the happy side effect that it allows us to parse a user ID from the DOM).

@emerick emerick force-pushed the new-twitter-verified-pubs branch from f405b7b to f5f463a Compare July 31, 2019 00:02
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution. Thanks for clearing it up 👍

@emerick emerick merged commit 70a2ea3 into master Jul 31, 2019
@emerick emerick deleted the new-twitter-verified-pubs branch July 31, 2019 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Twitter verified pubs info is not displayed in BR panel
4 participants