Mholloway has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/385072 )
Change subject: Summary 2.0: Introduce namespace whitelisting ...................................................................... Summary 2.0: Introduce namespace whitelisting Introduces the construct of a namespace whitelist for returning summary content for a page. For now, it includes only NS_MAIN (0). This shouldn't result in any functional change. Bug: T178420 Change-Id: I1d7173f311dc218f47f1e34d20bbbd45b59ebd6e --- M lib/mobile-util.js M routes/mobile-sections.js 2 files changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps refs/changes/72/385072/1 diff --git a/lib/mobile-util.js b/lib/mobile-util.js index 80564c6..1653a98 100644 --- a/lib/mobile-util.js +++ b/lib/mobile-util.js @@ -5,6 +5,7 @@ const HTTPError = require('./util').HTTPError; const mUtil = {}; +const NS_MAIN = 0; mUtil.CONTENT_TYPES = { mobileSections: { name: 'mobile-sections', version: '0.12.4' }, @@ -18,6 +19,8 @@ unpublished: { name: 'unpublished', version: '0.0.0' } }; +mUtil.SUMMARY_NS_WHITELIST = [ NS_MAIN ]; + mUtil.setContentType = function(res, spec, mainType = 'application/json') { if (!spec.name || !spec.version) { throw new HTTPError({ diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js index e37c35e..f863f7d 100644 --- a/routes/mobile-sections.js +++ b/routes/mobile-sections.js @@ -381,7 +381,7 @@ if (!lead) { return false; - } else if (lead.contentmodel || lead.ns !== 0) { + } else if (lead.contentmodel || !mUtil.SUMMARY_NS_WHITELIST.includes(lead.ns)) { code = 204; } else if (lead.intro) { summary = transforms.summarize(lead.intro); -- To view, visit https://gerrit.wikimedia.org/r/385072 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1d7173f311dc218f47f1e34d20bbbd45b59ebd6e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway <mhollo...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits