Skip to content

Commit

Permalink
fix: legacy broker account features (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbystedt authored Dec 24, 2024
1 parent ae49b49 commit f0c7759
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/intention/action.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export class ActionService {
data: {
action: action.action,
action_id: action.id,
key: action.service.target.environment
key: action.service.target?.environment
? 'action.service.target.environment'
: 'action.service.environment',
value: action.service.target.environment
value: action.service.target?.environment
? action.service.target.environment
: action.service.environment,
},
Expand Down
6 changes: 6 additions & 0 deletions src/intention/intention-util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class IntentionUtilService {
return UserEmbeddable.fromUserEntity(userEntity, accountEntity);
}

if (accountEntity.skipUserValidation) {
const embeddable = new UserEmbeddable();
embeddable.name = user.name;
return embeddable;
}

throw new Error('User not found.');
}
}
6 changes: 2 additions & 4 deletions src/intention/intention.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ export class IntentionService {
serviceEmbed.id = service._id;
}
const trace = TransactionEmbeddable.create();
const vaultEnvironment =
ENVIRONMENT_NAMES[this.computeVaultEnvironment(action, envMap)];

const vaultEnvironment = this.computeVaultEnvironment(action, envMap);
switch (action.action) {
case ACTION_NAMES.BACKUP:
return new BackupActionEmbeddable(
Expand Down Expand Up @@ -898,7 +896,7 @@ export class IntentionService {
private computeVaultEnvironment(
action: ActionEmbeddable | ActionDto,
envMap: EnvironmentEntityMap,
) {
): ENVIRONMENT_NAMES {
const env = this.actionUtil.environmentName(action);
const envDto = envMap[env];
if (
Expand Down
3 changes: 2 additions & 1 deletion src/persistence/entity/environment.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ObjectId } from 'mongodb';
import { ApiHideProperty } from '@nestjs/swagger';
import { VertexPointerEntity } from './vertex-pointer.entity';
import { COLLECTION_COLLATION_LOCALE } from '../../constants';
import { ENVIRONMENT_NAMES } from '../../intention/dto/constants.dto';

@Entity({ tableName: 'environment' })
export class EnvironmentEntity extends VertexPointerEntity {
Expand All @@ -22,7 +23,7 @@ export class EnvironmentEntity extends VertexPointerEntity {

@Property()
@Index({ options: { collation: { locale: COLLECTION_COLLATION_LOCALE } } })
name: string;
name: ENVIRONMENT_NAMES;

@Property()
short: string;
Expand Down

0 comments on commit f0c7759

Please sign in to comment.