Following/Unfollowing a feed when feedId != 0 using /read/following/mine/new works
Currently only unfollowing works (in certain edge cases). Following fails with response {"info":"invalid_feed","subscribed":false}
This issue was found when testing this PR https://github.com/wordpress-mobile/WordPress-Android/pull/12960
Here's https://github.com/wordpress-mobile/WordPress-Android/pull/12960#issuecomment-699662787 is some extra information about the different logic for determining which URL to use.
recommended_card implemented (Suggested) <- this is easier than clicking follow in a Post headersites/{blog_id}/follows/newnot related to device
Another example 9to5Google.com:
{"blog_id":146091833,"feed_id":86180988}
This feed has a feed url associated with it http://9to5google.com/feed

So the app tried to follow by feed url:

Followed blog id above is 22427743 (feed id: 109185821) which is a private site

And we're unauthorised to access it:

which is why I think we get an error in the mobile app.
Logs from app:
feed follow failed - {"info":"no_access","subscribed":false} - read/following/mine/new?source=android&url=http%3A%2F%2F9to5google.com%2Ffeed
Also noticed that we have two feeds with the same blog id, not sure if this is expected
/read/feed/109185821
/read/feed/86180988
cc @bluefuton
The sites that it wasn't possible to follow from the original issue (#12960) are:
The blog IDs are both private, hence the no_access response. I'm assuming they don't want that content indexed in Reader. Our post recommender should respect this and skip any private sites. Site recommendations already do this.
The other site was:
This site has moved URLs and has an out of date feed record. I've fixed it manually and the correct feed is:
https://wordpress.com/read/feeds/105000503
However, this site does not have any posts made in the last couple of years. I think we should not recommend sites that do not have any new posts in the last 12 months.
@bluefuton I also had problems with this one https://github.com/wordpress-mobile/WordPress-Android/pull/12960#issuecomment-698975017
Could you check why this was not working? It's probably one of the above reasons but it might be worth checking
Thanks!
@AdamGrzybkowski I was able to subscribe successfully to http://recliningstandards.com and it doesn't appear to be affected by either of the issues above. Do you recall what the response was from the API?
There is a reliable workaround here - always subscribe using the blog ID instead. I believe that's what Calypso Reader does when following sites via Reader Search and recommendations.
@bluefuton unfortunately, I don't :(
About subscribing with a blog ID - this was the solution proposed here but I wasn't sure if it's ok to do it that way.
@AdamGrzybkowski solution proposed here looks fine to me:
One solution to this problem could be simply using the util method from the point nr 2 instead of checking only the feedId value.
If we have a valid blogId I think it is safe to followByBlogId. It is only when we don't have a blogId when we should consider following by feedId.
It is a simple fix, right?
@ashiagr Yes, I will try to push it today/tomorrow :)
@ashiagr pushed the changes here https://github.com/wordpress-mobile/WordPress-Android/pull/12960/commits/6d083f04286ee76505329dbb350c18ff569527ce
Two changes were made to the API in response to this issue:
Thanks so much @AdamGrzybkowski , @bluefuton !!!
Most helpful comment
Thanks so much @AdamGrzybkowski , @bluefuton !!!