diff --git a/src/index.js b/src/index.js index b1a5471..374483f 100755 --- a/src/index.js +++ b/src/index.js @@ -121,15 +121,15 @@ router ctx.body = await publicPopular({ period }); }) .get("/public/latest", async ctx => { - const publicLatest = async () => { - const messages = await post.latest(); - return publicView({ messages }); - }; - ctx.body = await publicLatest(); + const messages = await post.latest(); + ctx.body = await publicView({ messages }); }) .get("/public/latest/extended", async ctx => { const messages = await post.latestExtended(); - + ctx.body = await publicView({ messages }); + }) + .get("/public/latest/topics", async ctx => { + const messages = await post.latestTopics(); ctx.body = await publicView({ messages }); }) .get("/author/:feed", async ctx => { diff --git a/src/models.js b/src/models.js index 067aec5..f12d781 100644 --- a/src/models.js +++ b/src/models.js @@ -679,6 +679,44 @@ module.exports = cooler => { return messages; }, + latestTopics: async () => { + const ssb = await cooler.connect(); + + const myFeedId = ssb.id; + + const options = configure({ + type: "post", + private: false + }); + + const source = await cooler.read(ssb.messagesByType, options); + + const extendedFilter = await socialFilter({ + following: true + }); + + const messages = await new Promise((resolve, reject) => { + pull( + source, + pull.filter( + message => + typeof message.value.content !== "string" && + message.value.content.root == null + ), + extendedFilter, + pull.take(maxMessages), + pull.collect((err, collectedMessages) => { + if (err) { + reject(err); + } else { + resolve(transform(ssb, collectedMessages, myFeedId)); + } + }) + ); + }); + + return messages; + }, popular: async ({ period }) => { const ssb = await cooler.connect(); diff --git a/src/views/template.js b/src/views/template.js index fc317ab..f081e65 100644 --- a/src/views/template.js +++ b/src/views/template.js @@ -46,6 +46,7 @@ module.exports = (...elements) => { li(a({ href: "/public/latest/extended" }, "πŸ—ΊοΈ Extended")), li(a({ href: "/" }, "πŸ“£ Popular")), li(a({ href: "/public/latest" }, "πŸ‡ Latest")), + li(a({ href: "/public/latest/topics" }, "πŸ“– Topics")), li(a({ href: "/profile" }, "🐱 Profile")), li(a({ href: "/mentions" }, "πŸ’¬ Mentions")), li(a({ href: "/inbox" }, "βœ‰οΈ Private")),