diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 0a8a98334dff8a7f816e8786dfdae693c7fbfa3b..d73e275640bb18a99ec61085879c87fd47e78add 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -158,6 +158,7 @@ describe('Test CLI wrapper', function () { expect(videoDetails.channel.name).to.equal('user_channel') expect(videoDetails.support).to.equal('support') expect(videoDetails.nsfw).to.be.true + expect(videoDetails.commentsEnabled).to.be.true } }) diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 4aa3d9ce84fec0ff02f223d58bca3f9be14bc3dc..2eec51aa490a96506864dd2955f3f19b0559b295 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -117,15 +117,22 @@ function buildCommonVideoOptions (command: Command) { } async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any) { - const booleanAttributes: { [id: string]: boolean } = {} + const defaultBooleanAttributes = { + nsfw: false, + commentsEnabled: true, + downloadEnabled: true, + waitTranscoding: true + } + + const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {} - for (const key of [ 'nsfw', 'commentsEnabled', 'downloadEnabled', 'waitTranscoding' ]) { + for (const key of Object.keys(defaultBooleanAttributes)) { if (command[ key ] !== undefined) { booleanAttributes[key] = command[ key ] } else if (defaultAttributes[key] !== undefined) { booleanAttributes[key] = defaultAttributes[key] } else { - booleanAttributes[key] = false + booleanAttributes[key] = defaultBooleanAttributes[key] } }