From aa3a854b6e1ee38fc8c5bb51d7a7b890c10bd4bc Mon Sep 17 00:00:00 2001 From: gawii0 Date: Fri, 24 Dec 2021 15:37:46 +0100 Subject: [PATCH 1/4] API light mode subreddit --- inc/teddit_api/handleSubreddit.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inc/teddit_api/handleSubreddit.js b/inc/teddit_api/handleSubreddit.js index eea258b..fd2d334 100644 --- a/inc/teddit_api/handleSubreddit.js +++ b/inc/teddit_api/handleSubreddit.js @@ -9,7 +9,8 @@ module.exports = function () { from, api_type, api_target, - subreddit + subreddit, + mode ) => { if (!config.api_enabled) { res.setHeader('Content-Type', 'application/json'); @@ -182,6 +183,10 @@ module.exports = function () { } } + if (mode === 'light') { + processed_json.selftext_html = null; + } + return res.end(JSON.stringify(processed_json)); } } From e0bf08132d29fb4e3abc96f9fc2072a4c69c6c61 Mon Sep 17 00:00:00 2001 From: gawii0 Date: Mon, 27 Dec 2021 18:17:15 +0100 Subject: [PATCH 2/4] Update handleTedditApiSubreddit 'routes/home.js' --- routes/home.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/routes/home.js b/routes/home.js index b68ba45..1430ffb 100644 --- a/routes/home.js +++ b/routes/home.js @@ -108,7 +108,8 @@ homeRoute.get('/:sort?', async (req, res, next) => { 'redis', api_type, api_target, - '/' + '/', + 'full' ); } else { let processed_json = await processJsonSubreddit( @@ -168,7 +169,8 @@ homeRoute.get('/:sort?', async (req, res, next) => { 'from_online', api_type, api_target, - '/' + '/', + 'full' ); } else { let processed_json = await processJsonSubreddit( From e870b9ea504182c283f8c55cfb81b2122cad7e2b Mon Sep 17 00:00:00 2001 From: gawii0 Date: Mon, 27 Dec 2021 18:18:21 +0100 Subject: [PATCH 3/4] Update handleTedditApiSubreddit 'routes/subreddit.js' --- routes/subreddit.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/subreddit.js b/routes/subreddit.js index 2a8f9d4..25e685d 100644 --- a/routes/subreddit.js +++ b/routes/subreddit.js @@ -373,6 +373,7 @@ subredditRoutes.get('/r/:subreddit/:sort?', (req, res, next) => { let api_req = req.query.api; let api_type = req.query.type; let api_target = req.query.target; + let api_mode = req.query.mode; if (req.query.hasOwnProperty('api')) api_req = true; else api_req = false; @@ -430,7 +431,8 @@ subredditRoutes.get('/r/:subreddit/:sort?', (req, res, next) => { 'redis', api_type, api_target, - subreddit + subreddit, + api_mode ); } else { let processed_json = await processJsonSubreddit( @@ -506,7 +508,8 @@ subredditRoutes.get('/r/:subreddit/:sort?', (req, res, next) => { 'from_online', api_type, api_target, - subreddit + subreddit, + api_mode ); } else { let processed_json = await processJsonSubreddit( From 0d2de6144454d8f15545765452bf0c21963c6d94 Mon Sep 17 00:00:00 2001 From: gawii0 Date: Mon, 27 Dec 2021 18:19:05 +0100 Subject: [PATCH 4/4] Update handleTedditApiSubreddit 'routes/user.js' --- routes/user.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/routes/user.js b/routes/user.js index 23b2150..d2402c0 100644 --- a/routes/user.js +++ b/routes/user.js @@ -327,7 +327,8 @@ userRoutes.get('/u/:user/m/:custom_feed/:sort?', (req, res, next) => { 'redis', api_type, api_target, - subreddit + subreddit, + 'full' ); } else { let processed_json = await processJsonSubreddit( @@ -397,7 +398,8 @@ userRoutes.get('/u/:user/m/:custom_feed/:sort?', (req, res, next) => { 'from_online', api_type, api_target, - subreddit + subreddit, + 'full' ); } else { let processed_json = await processJsonSubreddit(