@@ -46,22 +46,16 @@ import { validate as uuidValidate } from "uuid";
46
46
import { ctxUserId } from "../util/request-context" ;
47
47
import { ApplicationError , ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error" ;
48
48
import { EntitlementService } from "../billing/entitlement-service" ;
49
- import { Config } from "../config" ;
50
- import { ProjectsService } from "../projects/projects-service" ;
51
49
52
50
@injectable ( )
53
51
export class OrganizationServiceAPI implements ServiceImpl < typeof OrganizationServiceInterface > {
54
52
constructor (
55
- @inject ( Config )
56
- private readonly config : Config ,
57
53
@inject ( OrganizationService )
58
54
private readonly orgService : OrganizationService ,
59
55
@inject ( PublicAPIConverter )
60
56
private readonly apiConverter : PublicAPIConverter ,
61
57
@inject ( EntitlementService )
62
58
private readonly entitlementService : EntitlementService ,
63
- @inject ( ProjectsService )
64
- private readonly projectService : ProjectsService ,
65
59
) { }
66
60
67
61
async listOrganizationWorkspaceClasses (
@@ -188,7 +182,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
188
182
throw new ApplicationError ( ErrorCodes . BAD_REQUEST , "organizationId is required" ) ;
189
183
}
190
184
191
- const members = await this . orgService . listMembers ( ctxUserId ( ) , req . organizationId , true ) ;
185
+ const members = await this . orgService . listMembers ( ctxUserId ( ) , req . organizationId ) ;
192
186
//TODO pagination
193
187
const response = new ListOrganizationMembersResponse ( ) ;
194
188
response . members = members . map ( ( member ) => this . apiConverter . toOrganizationMember ( member ) ) ;
@@ -218,7 +212,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
218
212
this . apiConverter . fromOrgMemberRole ( req . role ) ,
219
213
) ;
220
214
const member = await this . orgService
221
- . listMembers ( ctxUserId ( ) , req . organizationId , true )
215
+ . listMembers ( ctxUserId ( ) , req . organizationId )
222
216
. then ( ( members ) => members . find ( ( member ) => member . userId === req . userId ) ) ;
223
217
return new UpdateOrganizationMemberResponse ( {
224
218
member : member && this . apiConverter . toOrganizationMember ( member ) ,
@@ -252,19 +246,6 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
252
246
const response = new GetOrganizationSettingsResponse ( ) ;
253
247
response . settings = this . apiConverter . toOrganizationSettings ( settings ) ;
254
248
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
-
268
249
return response ;
269
250
}
270
251
@@ -354,30 +335,8 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
354
335
update . maxParallelRunningWorkspaces = req . maxParallelRunningWorkspaces ;
355
336
}
356
337
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 ) ;
381
340
382
341
if (
383
342
! req . onboardingSettings . updateRecommendedRepositories &&
@@ -388,65 +347,8 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
388
347
"recommendedRepositories can only be set when updateRecommendedRepositories is true" ,
389
348
) ;
390
349
}
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
- } ;
449
350
}
351
+
450
352
if ( req . annotateGitCommits !== undefined ) {
451
353
update . annotateGitCommits = req . annotateGitCommits ;
452
354
}
0 commit comments