@@ -355,19 +355,36 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
355355 }
356356
357357 if ( req . onboardingSettings && Object . keys ( req . onboardingSettings ) . length > 0 ) {
358+ update . onboardingSettings = { } ;
359+
358360 if ( ! this . config . isDedicatedInstallation ) {
359361 throw new ApplicationError (
360362 ErrorCodes . BAD_REQUEST ,
361363 "onboardingSettings can only be set on enterprise installations" ,
362364 ) ;
363365 }
364- if ( ( req . onboardingSettings . internalLink ?. length ?? 0 ) > 255 ) {
365- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "internalLink must be <= 255 characters" ) ;
366+
367+ if ( req . onboardingSettings . internalLink ) {
368+ if ( req . onboardingSettings . internalLink . length > 255 ) {
369+ throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "internalLink must be <= 255 characters long" ) ;
370+ }
371+
372+ update . onboardingSettings . internalLink = req . onboardingSettings . internalLink ;
366373 }
367374
368375 if (
369- req . onboardingSettings . recommendedRepositories &&
370- req . onboardingSettings . updateRecommendedRepositories
376+ ! req . onboardingSettings . updateRecommendedRepositories &&
377+ req . onboardingSettings . recommendedRepositories . length > 0
378+ ) {
379+ throw new ApplicationError (
380+ ErrorCodes . BAD_REQUEST ,
381+ "recommendedRepositories can only be set when updateRecommendedRepositories is true" ,
382+ ) ;
383+ }
384+
385+ if (
386+ req . onboardingSettings . updateRecommendedRepositories &&
387+ req . onboardingSettings . recommendedRepositories
371388 ) {
372389 if ( req . onboardingSettings . recommendedRepositories . length > 3 ) {
373390 throw new ApplicationError (
@@ -385,6 +402,8 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
385402 throw new ApplicationError ( ErrorCodes . BAD_REQUEST , `repository ${ configurationId } not found` ) ;
386403 }
387404 }
405+
406+ update . onboardingSettings . recommendedRepositories = req . onboardingSettings . recommendedRepositories ;
388407 }
389408
390409 if (
@@ -411,9 +430,15 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
411430 ) {
412431 throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "welcomeMessage must not be empty when enabled" ) ;
413432 }
433+
434+ update . onboardingSettings . welcomeMessage = req . onboardingSettings . welcomeMessage ;
414435 }
415436
416- update . onboardingSettings = req . onboardingSettings ;
437+ const existingOnboardingSettings = await this . orgService . getSettings ( ctxUserId ( ) , req . organizationId ) ;
438+ update . onboardingSettings = {
439+ ...existingOnboardingSettings . onboardingSettings ,
440+ ...update . onboardingSettings ,
441+ } ;
417442 }
418443 if ( req . annotateGitCommits !== undefined ) {
419444 update . annotateGitCommits = req . annotateGitCommits ;
0 commit comments