Skip to content

Commit

Permalink
Merge branch 'release/1.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
PofMagicfingers committed Feb 5, 2021
2 parents de41307 + c09676c commit 93b707f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podcloud-feeds",
"version": "1.7.1",
"version": "1.7.2",
"description": "GraphQL API for podcloud",
"scripts": {
"test": "NODE_ENV=test mocha --opts test/mocha.opts",
Expand Down
1 change: 1 addition & 0 deletions src/schema/queries/resolvers/podcastItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const podcastItem = function(obj, args, context, info) {
if (err) {
reject(err);
} else {
item.preview = true; // Items loaded by ID should include preview token
if (item && item.feed_id) {
Feed.findOne({ _id: item.feed_id }).exec(function(err, feed) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/types/enclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Enclosure {
duration: Int!
size: BigInt!
type: String!
url: String!
url(purpose: String): String!
cover: Cover!
}
`;
Expand Down
4 changes: 3 additions & 1 deletion src/schema/types/resolvers/enclosure.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const Enclosure = {

return `${prefix}${
ctx.hosts.stats
}/${identifier}/${item_slug}/enclosure.${enclosure_sha256}${enclosure_ext}?p=f`;
}/${identifier}/${item_slug}/enclosure.${enclosure_sha256}${enclosure_ext}?p=${
empty(args.purpose) ? "dl" : args.purpose
}${enclosure.item.preview ? `&preview=${enclosure.item.id}` : ""}`;
},
cover(enclosure) {
let cover = null;
Expand Down
5 changes: 5 additions & 0 deletions src/schema/types/resolvers/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const Playlist = {
return Promise.resolve();
}

if (item.published_at <= new Date()) {
debug("Ignoring unpublished episode");
return Promise.resolve();
}

if (!cached_feeds[item.feed_id]) {
debug("no cached feeds promise for feed_id : ", item.feed_id);
cached_feeds[item.feed_id] = new Promise((resolve, reject) => {
Expand Down
77 changes: 70 additions & 7 deletions test/src/schema/types/enclosure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("Enclosure Graph Object", () => {

const enclosureObject = {
item: {
id: "this_is_my_id",
_slugs: ["toto", "tata"],
feed: { identifier: "blog-de-toto" },
updated_at: new Date(1337 * 1000)
Expand All @@ -23,7 +24,7 @@ describe("Enclosure Graph Object", () => {
mime_type: "audio/mpeg+test",
filename: "afile.ext",
meta_url: {
path: "http://anurl.test/afile.mp3?p=f"
path: "http://anurl.test/afile.mp3"
}
};

Expand Down Expand Up @@ -111,6 +112,68 @@ describe("Enclosure Graph Object", () => {
);
});

it("should resolve url with default purpose", () => {
expect(enclosureFields.url.resolve(enclosureObject, {}, context)).to.equals(
"https://" +
context.hosts.stats +
"/blog-de-toto/tata/enclosure.blabla.ext?p=dl"
);
});

it("should resolve url with custom purpose", () => {
expect(
enclosureFields.url.resolve(enclosureObject, { purpose: "f" }, context)
).to.equals(
"https://" +
context.hosts.stats +
"/blog-de-toto/tata/enclosure.blabla.ext?p=f"
);
});

it("should resolve url without preview", () => {
expect(enclosureFields.url.resolve(enclosureObject, {}, context)).to.equals(
"https://" +
context.hosts.stats +
"/blog-de-toto/tata/enclosure.blabla" +
".ext?p=dl"
);

expect(
enclosureFields.url.resolve(
{
...enclosureObject,
item: { ...enclosureObject.item, preview: false }
},
{},
context
)
).to.equals(
"https://" +
context.hosts.stats +
"/blog-de-toto/tata/enclosure.blabla" +
".ext?p=dl"
);
});

it("should resolve url with preview", () => {
expect(
enclosureFields.url.resolve(
{
...enclosureObject,
item: { ...enclosureObject.item, preview: true }
},
{},
context
)
).to.equals(
"https://" +
context.hosts.stats +
"/blog-de-toto/tata/enclosure.blabla" +
".ext?p=dl&preview=" +
enclosureObject.item.id
);
});

it("should resolve url with correct media_type", () => {
expect(
enclosureFields.url.resolve(
Expand All @@ -126,7 +189,7 @@ describe("Enclosure Graph Object", () => {
context.hosts.stats +
"/blog-de-toto/tata/enclosure." +
"blabla" +
".pouet?p=f"
".pouet?p=dl"
);
});

Expand All @@ -145,7 +208,7 @@ describe("Enclosure Graph Object", () => {
context.hosts.stats +
"/blog-de-toto/tata/enclosure." +
"blabla" +
".ext?p=f"
".ext?p=dl"
);
});

Expand All @@ -165,7 +228,7 @@ describe("Enclosure Graph Object", () => {
context.hosts.stats +
"/blog-de-toto/tata/enclosure." +
"blabla" +
".mp3?p=f"
".mp3?p=dl"
);
});

Expand All @@ -192,7 +255,7 @@ describe("Enclosure Graph Object", () => {
context.hosts.stats +
"/blog-de-toto/tata/enclosure." +
"blabla" +
".mp3?p=f"
".mp3?p=dl"
);
});

Expand All @@ -211,8 +274,8 @@ describe("Enclosure Graph Object", () => {
context.hosts.stats +
"/blog-de-toto/tata/enclosure." +
// this is meta_url.path sha256
"85e551c61511d36350535b2688a6bdb40845301414e630e2f8a03c252ccf37de" +
".ext?p=f"
"d281e6f02163d971e1218a178ad09fbf09deb41d8e9aaed19ff1a440674221b2" +
".ext?p=dl"
);
});
});

0 comments on commit 93b707f

Please sign in to comment.