@@ -46,22 +46,16 @@ import { validate as uuidValidate } from "uuid";
4646import { ctxUserId } from "../util/request-context" ;
4747import { ApplicationError , ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
4848import { EntitlementService } from "../billing/entitlement-service" ;
49- import { Config } from "../config" ;
50- import { ProjectsService } from "../projects/projects-service" ;
5149
5250@injectable ( )
5351export class OrganizationServiceAPI implements ServiceImpl < typeof OrganizationServiceInterface > {
5452 constructor (
55- @inject ( Config )
56- private readonly config : Config ,
5753 @inject ( OrganizationService )
5854 private readonly orgService : OrganizationService ,
5955 @inject ( PublicAPIConverter )
6056 private readonly apiConverter : PublicAPIConverter ,
6157 @inject ( EntitlementService )
6258 private readonly entitlementService : EntitlementService ,
63- @inject ( ProjectsService )
64- private readonly projectService : ProjectsService ,
6559 ) { }
6660
6761 async listOrganizationWorkspaceClasses (
@@ -188,7 +182,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
188182 throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "organizationId is required" ) ;
189183 }
190184
191- const members = await this . orgService . listMembers ( ctxUserId ( ) , req . organizationId , true ) ;
185+ const members = await this . orgService . listMembers ( ctxUserId ( ) , req . organizationId ) ;
192186 //TODO pagination
193187 const response = new ListOrganizationMembersResponse ( ) ;
194188 response . members = members . map ( ( member ) => this . apiConverter . toOrganizationMember ( member ) ) ;
@@ -218,7 +212,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
218212 this . apiConverter . fromOrgMemberRole ( req . role ) ,
219213 ) ;
220214 const member = await this . orgService
221- . listMembers ( ctxUserId ( ) , req . organizationId , true )
215+ . listMembers ( ctxUserId ( ) , req . organizationId )
222216 . then ( ( members ) => members . find ( ( member ) => member . userId === req . userId ) ) ;
223217 return new UpdateOrganizationMemberResponse ( {
224218 member : member && this . apiConverter . toOrganizationMember ( member ) ,
@@ -252,19 +246,6 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
252246 const response = new GetOrganizationSettingsResponse ( ) ;
253247 response . settings = this . apiConverter . toOrganizationSettings ( settings ) ;
254248
255- // resolve the avatar URL for the featured member in the welcome message
256- const onboardingWelcomeMessageFeaturedMemberId =
257- response . settings . onboardingSettings ?. welcomeMessage ?. featuredMemberId ;
258- if ( onboardingWelcomeMessageFeaturedMemberId ) {
259- const member = await this . orgService
260- . getOrganizationMember ( ctxUserId ( ) , req . organizationId , onboardingWelcomeMessageFeaturedMemberId , true )
261- . catch ( ( ) => undefined ) ;
262- if ( member ?. user . avatarUrl && response ?. settings ?. onboardingSettings ?. welcomeMessage ) {
263- response . settings . onboardingSettings . welcomeMessage . featuredMemberResolvedAvatarUrl =
264- member . user . avatarUrl ;
265- }
266- }
267-
268249 return response ;
269250 }
270251
@@ -354,30 +335,8 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
354335 update . maxParallelRunningWorkspaces = req . maxParallelRunningWorkspaces ;
355336 }
356337
357- if ( req . onboardingSettings && Object . keys ( req . onboardingSettings ) . length > 0 ) {
358- update . onboardingSettings = { } ;
359-
360- if ( ! this . config . isDedicatedInstallation ) {
361- throw new ApplicationError (
362- ErrorCodes . BAD_REQUEST ,
363- "onboardingSettings can only be set on enterprise installations" ,
364- ) ;
365- }
366-
367- if ( req . onboardingSettings . welcomeMessage ?. featuredMemberResolvedAvatarUrl ) {
368- throw new ApplicationError (
369- ErrorCodes . BAD_REQUEST ,
370- "featuredMemberResolvedAvatarUrl is not allowed to be set" ,
371- ) ;
372- }
373-
374- if ( req . onboardingSettings . internalLink ) {
375- if ( req . onboardingSettings . internalLink . length > 255 ) {
376- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "internalLink must be <= 255 characters long" ) ;
377- }
378-
379- update . onboardingSettings . internalLink = req . onboardingSettings . internalLink ;
380- }
338+ if ( req . onboardingSettings ) {
339+ update . onboardingSettings = this . apiConverter . fromOnboardingSettings ( req . onboardingSettings ) ;
381340
382341 if (
383342 ! req . onboardingSettings . updateRecommendedRepositories &&
@@ -388,65 +347,8 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
388347 "recommendedRepositories can only be set when updateRecommendedRepositories is true" ,
389348 ) ;
390349 }
391-
392- if (
393- req . onboardingSettings . updateRecommendedRepositories &&
394- req . onboardingSettings . recommendedRepositories
395- ) {
396- if ( req . onboardingSettings . recommendedRepositories . length > 3 ) {
397- throw new ApplicationError (
398- ErrorCodes . BAD_REQUEST ,
399- "there can't be more than 3 recommendedRepositories" ,
400- ) ;
401- }
402- for ( const configurationId of req . onboardingSettings . recommendedRepositories ) {
403- if ( ! uuidValidate ( configurationId ) ) {
404- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "recommendedRepositories must be UUIDs" ) ;
405- }
406-
407- const project = await this . projectService . getProject ( ctxUserId ( ) , configurationId ) ;
408- if ( ! project ) {
409- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , `repository ${ configurationId } not found` ) ;
410- }
411- }
412-
413- update . onboardingSettings . recommendedRepositories = req . onboardingSettings . recommendedRepositories ;
414- }
415-
416- if (
417- req . onboardingSettings . welcomeMessage &&
418- Object . keys ( req . onboardingSettings . welcomeMessage ) . length > 0
419- ) {
420- if ( req . onboardingSettings . welcomeMessage . featuredMemberId ) {
421- const member = await this . orgService
422- . getOrganizationMember (
423- ctxUserId ( ) ,
424- req . organizationId ,
425- req . onboardingSettings . welcomeMessage . featuredMemberId ,
426- true ,
427- )
428- . catch ( ( ) => undefined ) ;
429- if ( ! member ) {
430- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "featuredMemberId not found" ) ;
431- }
432- }
433-
434- if (
435- req . onboardingSettings . welcomeMessage . enabled &&
436- req . onboardingSettings . welcomeMessage . message ?. length === 0
437- ) {
438- throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "welcomeMessage must not be empty when enabled" ) ;
439- }
440-
441- update . onboardingSettings . welcomeMessage = req . onboardingSettings . welcomeMessage ;
442- }
443-
444- const existingOnboardingSettings = await this . orgService . getSettings ( ctxUserId ( ) , req . organizationId ) ;
445- update . onboardingSettings = {
446- ...existingOnboardingSettings . onboardingSettings ,
447- ...update . onboardingSettings ,
448- } ;
449350 }
351+
450352 if ( req . annotateGitCommits !== undefined ) {
451353 update . annotateGitCommits = req . annotateGitCommits ;
452354 }
0 commit comments