ActivityPub-federated video streaming platform using P2P directly in your web browser
Implement getServerListeningConfig plugin helper
Chocobozzz60bab7b540de
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.tsindex e75c0b9942..66383af46a 100644--- a/server/lib/plugins/plugin-helpers-builder.ts+++ b/server/lib/plugins/plugin-helpers-builder.ts@@ -209,6 +209,10 @@ function buildConfigHelpers () {return WEBSERVER.URL},+ getServerListeningConfig () {+ return { hostname: CONFIG.LISTEN.HOSTNAME, port: CONFIG.LISTEN.PORT }+ },+getServerConfig () {return ServerConfigManager.Instance.getServerConfig()}diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.jsindex 3e848c49e0..b10177b452 100644--- a/server/tests/fixtures/peertube-plugin-test-four/main.js+++ b/server/tests/fixtures/peertube-plugin-test-four/main.js@@ -76,6 +76,12 @@ async function register ({return res.json({ serverConfig })})+ router.get('/server-listening-config', async (req, res) => {+ const config = await peertubeHelpers.config.getServerListeningConfig()++ return res.json({ config })+ })+router.get('/static-route', async (req, res) => {const staticRoute = peertubeHelpers.plugin.getBaseStaticRoute()diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.tsindex 038e3f0d6c..e25992723d 100644--- a/server/tests/plugins/plugin-helpers.ts+++ b/server/tests/plugins/plugin-helpers.ts@@ -64,6 +64,18 @@ describe('Test plugin helpers', function () {await servers[0].servers.waitUntilLog(`server url is ${servers[0].url}`)})+ it('Should have the correct listening config', async function () {+ const res = await makeGetRequest({+ url: servers[0].url,+ path: '/plugins/test-four/router/server-listening-config',+ expectedStatus: HttpStatusCode.OK_200+ })++ expect(res.body.config).to.exist+ expect(res.body.config.hostname).to.equal('::')+ expect(res.body.config.port).to.equal(servers[0].port)+ })+it('Should have the correct config', async function () {const res = await makeGetRequest({url: servers[0].url,diff --git a/server/types/plugins/register-server-option.model.ts b/server/types/plugins/register-server-option.model.tsindex 1e2bd830eb..df419fff47 100644--- a/server/types/plugins/register-server-option.model.ts+++ b/server/types/plugins/register-server-option.model.ts@@ -71,6 +71,9 @@ export type PeerTubeHelpers = {config: {getWebserverUrl: () => string+ // PeerTube >= 5.1+ getServerListeningConfig: () => { hostname: string, port: number }+getServerConfig: () => Promise<ServerConfig>}