1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-09 01:17:06 +02:00

Fix/user added event (#1437)

* 4.9.0-beta.1

* chore: update unleash frontend

* 4.9.0-beta.2

* fix: add user email to project user events
This commit is contained in:
Fredrik Strand Oseberg 2022-03-16 08:44:30 +01:00 committed by GitHub
parent 9c3683cf13
commit a236a61623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "unleash-server", "name": "unleash-server",
"description": "Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.", "description": "Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.",
"version": "4.9.0-beta.0", "version": "4.9.0-beta.2",
"keywords": [ "keywords": [
"unleash", "unleash",
"feature toggle", "feature toggle",

View File

@ -37,6 +37,7 @@ import IncompatibleProjectError from '../error/incompatible-project-error';
import { DEFAULT_PROJECT } from '../types/project'; import { DEFAULT_PROJECT } from '../types/project';
import { IFeatureTagStore } from 'lib/types/stores/feature-tag-store'; import { IFeatureTagStore } from 'lib/types/stores/feature-tag-store';
import ProjectWithoutOwnerError from '../error/project-without-owner-error'; import ProjectWithoutOwnerError from '../error/project-without-owner-error';
import { IUserStore } from 'lib/types/stores/user-store';
const getCreatedBy = (user: User) => user.email || user.username; const getCreatedBy = (user: User) => user.email || user.username;
@ -66,6 +67,8 @@ export default class ProjectService {
private tagStore: IFeatureTagStore; private tagStore: IFeatureTagStore;
private userStore: IUserStore;
constructor( constructor(
{ {
projectStore, projectStore,
@ -75,6 +78,7 @@ export default class ProjectService {
environmentStore, environmentStore,
featureEnvironmentStore, featureEnvironmentStore,
featureTagStore, featureTagStore,
userStore,
}: Pick< }: Pick<
IUnleashStores, IUnleashStores,
| 'projectStore' | 'projectStore'
@ -84,6 +88,7 @@ export default class ProjectService {
| 'environmentStore' | 'environmentStore'
| 'featureEnvironmentStore' | 'featureEnvironmentStore'
| 'featureTagStore' | 'featureTagStore'
| 'userStore'
>, >,
config: IUnleashConfig, config: IUnleashConfig,
accessService: AccessService, accessService: AccessService,
@ -98,6 +103,7 @@ export default class ProjectService {
this.featureTypeStore = featureTypeStore; this.featureTypeStore = featureTypeStore;
this.featureToggleService = featureToggleService; this.featureToggleService = featureToggleService;
this.tagStore = featureTagStore; this.tagStore = featureTagStore;
this.userStore = userStore;
this.logger = config.getLogger('services/project-service.js'); this.logger = config.getLogger('services/project-service.js');
} }
@ -280,6 +286,7 @@ export default class ProjectService {
const [roles, users] = await this.accessService.getProjectRoleUsers( const [roles, users] = await this.accessService.getProjectRoleUsers(
projectId, projectId,
); );
const user = await this.userStore.get(userId);
const role = roles.find((r) => r.id === roleId); const role = roles.find((r) => r.id === roleId);
if (!role) { if (!role) {
@ -299,7 +306,12 @@ export default class ProjectService {
new ProjectUserAddedEvent({ new ProjectUserAddedEvent({
project: projectId, project: projectId,
createdBy, createdBy,
data: { roleId, userId, roleName: role.name }, data: {
roleId,
userId,
roleName: role.name,
email: user.email,
},
}), }),
); );
} }
@ -317,11 +329,18 @@ export default class ProjectService {
await this.accessService.removeUserFromRole(userId, role.id, projectId); await this.accessService.removeUserFromRole(userId, role.id, projectId);
const user = await this.userStore.get(userId);
await this.eventStore.store( await this.eventStore.store(
new ProjectUserRemovedEvent({ new ProjectUserRemovedEvent({
project: projectId, project: projectId,
createdBy, createdBy,
preData: { roleId, userId, roleName: role.name }, preData: {
roleId,
userId,
roleName: role.name,
email: user.email,
},
}), }),
); );
} }
@ -389,8 +408,14 @@ export default class ProjectService {
userId, userId,
roleId: currentRole.id, roleId: currentRole.id,
roleName: currentRole.name, roleName: currentRole.name,
email: user.email,
},
data: {
userId,
roleId,
roleName: role.name,
email: user.email,
}, },
data: { userId, roleId, roleName: role.name },
}), }),
); );
} }