diff --git a/lib/templateFactory.js b/lib/templateFactory.js index 894b8dbb..b7ba448d 100644 --- a/lib/templateFactory.js +++ b/lib/templateFactory.js @@ -383,7 +383,13 @@ class TemplateFactory extends BaseFactory { const eventFactory = EventFactory.getInstance(); const pipelineData = await pipelineFactory.list(pipelineConfig); - const eventIds = pipelineData.filter(p => p.lastEventId !== null).map(p => p.lastEventId); + const publicPipelineData = pipelineData.filter(p => { + const privatePipeline = p.scmRepo && p.scmRepo.private; + const setToPublic = p.settings && p.settings.public; + + return !privatePipeline || setToPublic; + }); + const eventIds = publicPipelineData.filter(p => p.lastEventId !== null).map(p => p.lastEventId); const eventConfig = { params: { id: eventIds }, readOnly: true @@ -395,7 +401,7 @@ class TemplateFactory extends BaseFactory { return map; }, {}); - return pipelineData.map(p => { + return publicPipelineData.map(p => { return { id: p.id, name: p.name, diff --git a/test/lib/templateFactory.test.js b/test/lib/templateFactory.test.js index c5efb7e9..c1c6488d 100644 --- a/test/lib/templateFactory.test.js +++ b/test/lib/templateFactory.test.js @@ -1403,7 +1403,7 @@ describe('Template Factory', () => { name: 'nathom/sd-uses-template', url: 'https://github.com/test/repo/tree/main/pipe3', rootDir: 'pipe3', - private: false + private: true }, lastRun: '2023-08-31T18:18:37.501Z', admins: { nathom: true } @@ -1461,11 +1461,29 @@ describe('Template Factory', () => { name: 'nathom/sd-uses-template', url: 'https://github.com/test/repo/tree/main/pipe3', rootDir: 'pipe3', - private: false + private: true }, + settings: { public: true }, createTime: '2023-08-17T18:18:37.501Z', admins: { nathom: true }, lastEventId: 1 + }, + + { + id: 3, + name: 'nathom/sd-uses-template', + scmUri: 'github.com:672032066:main:pipe4', + scmContext: 'github:github.com', + scmRepo: { + branch: 'main', + name: 'nathom/sd-uses-template', + url: 'https://github.com/test/repo/tree/main/pipe4', + rootDir: 'pipe4', + private: true + }, + createTime: '2023-08-17T18:18:37.501Z', + admins: { nathom: true }, + lastEventId: 3 } ];