X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fserver%2Fconfig.ts;h=b7011085260e64a5b15e9b0314db9b8bd6c5b6b0;hb=428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba;hp=a5f5989e099f7bc0cb0ef2c81e2d09f2eed624af;hpb=79ad1706f3cf009e04db9cd9e6a721801d93e64e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index a5f5989e0..b70110852 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts @@ -1,5 +1,7 @@ import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' import { CustomConfig } from '../../models/server/custom-config.model' +import { DeepPartial, HttpStatusCode } from '@shared/core-utils' +import { merge } from 'lodash' function getConfig (url: string) { const path = '/api/v1/config' @@ -7,7 +9,7 @@ function getConfig (url: string) { return makeGetRequest({ url, path, - statusCodeExpected: 200 + statusCodeExpected: HttpStatusCode.OK_200 }) } @@ -17,11 +19,11 @@ function getAbout (url: string) { return makeGetRequest({ url, path, - statusCodeExpected: 200 + statusCodeExpected: HttpStatusCode.OK_200 }) } -function getCustomConfig (url: string, token: string, statusCodeExpected = 200) { +function getCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { const path = '/api/v1/config/custom' return makeGetRequest({ @@ -32,7 +34,7 @@ function getCustomConfig (url: string, token: string, statusCodeExpected = 200) }) } -function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) { +function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = HttpStatusCode.OK_200) { const path = '/api/v1/config/custom' return makePutBodyRequest({ @@ -44,21 +46,38 @@ function updateCustomConfig (url: string, token: string, newCustomConfig: Custom }) } -function updateCustomSubConfig (url: string, token: string, newConfig: any) { +function updateCustomSubConfig (url: string, token: string, newConfig: DeepPartial) { const updateParams: CustomConfig = { instance: { name: 'PeerTube updated', shortDescription: 'my short description', description: 'my super description', terms: 'my super terms', - defaultClientRoute: '/videos/recently-added', + codeOfConduct: 'my super coc', + + creationReason: 'my super creation reason', + moderationInformation: 'my super moderation information', + administrator: 'Kuja', + maintenanceLifetime: 'forever', + businessModel: 'my super business model', + hardwareInformation: '2vCore 3GB RAM', + + languages: [ 'en', 'es' ], + categories: [ 1, 2 ], + isNSFW: true, defaultNSFWPolicy: 'blur', + + defaultClientRoute: '/videos/recently-added', + customizations: { javascript: 'alert("coucou")', css: 'body { background-color: red; }' } }, + theme: { + default: 'default' + }, services: { twitter: { username: '@MySuperUsername', @@ -71,6 +90,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { }, captions: { size: 3 + }, + torrents: { + size: 4 } }, signup: { @@ -93,19 +115,49 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { allowAdditionalExtensions: true, allowAudioFiles: true, threads: 1, + concurrency: 3, + profile: 'default', resolutions: { + '0p': false, '240p': false, '360p': true, '480p': true, '720p': false, - '1080p': false + '1080p': false, + '1440p': false, + '2160p': false + }, + webtorrent: { + enabled: true }, hls: { enabled: false } }, + live: { + enabled: true, + allowReplay: false, + maxDuration: -1, + maxInstanceLives: -1, + maxUserLives: 50, + transcoding: { + enabled: true, + threads: 4, + profile: 'default', + resolutions: { + '240p': true, + '360p': true, + '480p': true, + '720p': true, + '1080p': true, + '1440p': true, + '2160p': true + } + } + }, import: { videos: { + concurrency: 3, http: { enabled: false }, @@ -114,6 +166,14 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { } } }, + trending: { + videos: { + algorithms: { + enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ], + default: 'hot' + } + } + }, autoBlacklist: { videos: { ofUsers: { @@ -126,15 +186,56 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { enabled: true, manualApproval: false } + }, + followings: { + instance: { + autoFollowBack: { + enabled: false + }, + autoFollowIndex: { + indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts', + enabled: false + } + } + }, + broadcastMessage: { + enabled: true, + level: 'warning', + message: 'hello', + dismissable: true + }, + search: { + remoteUri: { + users: true, + anonymous: true + }, + searchIndex: { + enabled: true, + url: 'https://search.joinpeertube.org', + disableLocalSearch: true, + isDefaultSearch: true + } } } - Object.assign(updateParams, newConfig) + merge(updateParams, newConfig) return updateCustomConfig(url, token, updateParams) } -function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { +function getCustomConfigResolutions (enabled: boolean) { + return { + '240p': enabled, + '360p': enabled, + '480p': enabled, + '720p': enabled, + '1080p': enabled, + '1440p': enabled, + '2160p': enabled + } +} + +function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { const path = '/api/v1/config/custom' return makeDeleteRequest({ @@ -153,5 +254,6 @@ export { updateCustomConfig, getAbout, deleteCustomConfig, - updateCustomSubConfig + updateCustomSubConfig, + getCustomConfigResolutions }