Bug 1441931 - Use open_url provided by Pocket for 'saved to pocket' items in highlights
MozReview-Commit-ID: 5St8NablevZ
--- a/browser/extensions/pocket/content/pktApi.jsm
+++ b/browser/extensions/pocket/content/pktApi.jsm
@@ -617,17 +617,17 @@ var pktApi = (function() {
/**
* Helper function to get a user's pocket stories
* @return {Boolean} Returns Boolean whether the api call started sucessfully
*/
function retrieve(data = {}, options = {}) {
const requestData = Object.assign({}, data, {access_token: getAccessToken()});
return apiRequest({
- path: "/get",
+ path: "/firefox/get",
data: requestData,
success: options.success,
error: options.error
});
}
/**
* Helper function to get current signup AB group the user is in
--- a/toolkit/modules/NewTabUtils.jsm
+++ b/toolkit/modules/NewTabUtils.jsm
@@ -1042,17 +1042,18 @@ var ActivityStreamProvider = {
let items = Object.values(data.list)
// status "0" means not archived or deleted
.filter(item => item.status === "0")
.map(item => ({
description: item.excerpt,
preview_image_url: item.image && item.image.src,
title: item.resolved_title,
url: item.resolved_url,
- pocket_id: item.item_id
+ pocket_id: item.item_id,
+ open_url: item.open_url
}));
return this._processHighlights(items, aOptions, "pocket");
},
/**
* Get most-recently-created visited bookmarks for Activity Stream.
*
--- a/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
@@ -522,16 +522,17 @@ add_task(async function getHighlightsWit
const fakeResponse = {
list: {
"123": {
image: {src: "foo.com/img.png"},
excerpt: "A description for foo",
resolved_title: "A title for foo",
resolved_url: "http://www.foo.com",
item_id: "123",
+ open_url: "getpocket.com/itemID",
status: "0"
},
"456": {
item_id: "456",
status: "2",
}
}
};
@@ -558,31 +559,33 @@ add_task(async function getHighlightsWit
let pocketItem = fakeResponse.list["123"];
let currentLink = links[1];
Assert.equal(currentLink.url, pocketItem.resolved_url, "Correct Pocket item");
Assert.equal(currentLink.type, "pocket", "Attached the correct type");
Assert.equal(currentLink.preview_image_url, pocketItem.image.src, "Correct preview image was added");
Assert.equal(currentLink.title, pocketItem.resolved_title, "Correct title was added");
Assert.equal(currentLink.description, pocketItem.excerpt, "Correct description was added");
Assert.equal(currentLink.pocket_id, pocketItem.item_id, "item_id was preserved");
+ Assert.equal(currentLink.open_url, pocketItem.open_url, "open_url was preserved");
NewTabUtils.activityStreamLinks._savedPocketStories = null;
});
add_task(async function getHighlightsWithPocketCached() {
await setUpActivityStreamTest();
let fakeResponse = {
list: {
"123": {
image: {src: "foo.com/img.png"},
excerpt: "A description for foo",
resolved_title: "A title for foo",
resolved_url: "http://www.foo.com",
item_id: "123",
+ open_url: "getpocket.com/itemID",
status: "0"
},
"456": {
item_id: "456",
status: "2",
}
}
};
@@ -596,16 +599,17 @@ add_task(async function getHighlightsWit
// Update what the response would be
fakeResponse.list["789"] = {
image: {src: "bar.com/img.png"},
excerpt: "A description for bar",
resolved_title: "A title for bar",
resolved_url: "http://www.bar.com",
item_id: "789",
+ open_url: "getpocket.com/itemID",
status: "0"
};
// Call getHighlights again - this time we should get the cached links since we just updated
links = await provider.getHighlights();
Assert.equal(links.length, 1, "We still got 1 link back for highlights");
Assert.equal(links[0].url, fakeResponse.list["123"].resolved_url, "It was still the same pocket story");