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

fix: wip project events

This commit is contained in:
Ivar Conradi Østhus 2022-01-14 10:00:21 +01:00
parent c1826ca79a
commit cab9f5dffc
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
2 changed files with 26 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import { nameType } from '../routes/util';
import { projectSchema } from './project-schema'; import { projectSchema } from './project-schema';
import NotFoundError from '../error/notfound-error'; import NotFoundError from '../error/notfound-error';
import { import {
ProjectUserAddedEvent,
PROJECT_CREATED, PROJECT_CREATED,
PROJECT_DELETED, PROJECT_DELETED,
PROJECT_UPDATED, PROJECT_UPDATED,
@ -288,6 +289,7 @@ export default class ProjectService {
projectId: string, projectId: string,
roleId: number, roleId: number,
userId: number, userId: number,
createdBy: string,
): Promise<void> { ): Promise<void> {
const [roles, users] = await this.accessService.getProjectRoleUsers( const [roles, users] = await this.accessService.getProjectRoleUsers(
projectId, projectId,
@ -306,6 +308,14 @@ export default class ProjectService {
} }
await this.accessService.addUserToRole(userId, role.id, projectId); await this.accessService.addUserToRole(userId, role.id, projectId);
this.eventStore.store(
new ProjectUserAddedEvent({
project: projectId,
createdBy,
data: { roleId, userId },
}),
);
} }
// TODO: should be an event too // TODO: should be an event too

View File

@ -39,6 +39,9 @@ export const PROJECT_CREATED = 'project-created';
export const PROJECT_UPDATED = 'project-updated'; export const PROJECT_UPDATED = 'project-updated';
export const PROJECT_DELETED = 'project-deleted'; export const PROJECT_DELETED = 'project-deleted';
export const PROJECT_IMPORT = 'project-import'; export const PROJECT_IMPORT = 'project-import';
export const PROJECT_USER_ADDED = 'project-user-added';
export const PROJECT_USER_REMOVED = 'project-user-removed';
export const PROJECT_USER_UPDATED = 'project-user-updated';
export const DROP_PROJECTS = 'drop-projects'; export const DROP_PROJECTS = 'drop-projects';
export const TAG_CREATED = 'tag-created'; export const TAG_CREATED = 'tag-created';
export const TAG_DELETED = 'tag-deleted'; export const TAG_DELETED = 'tag-deleted';
@ -378,3 +381,16 @@ export class FeatureStrategyRemoveEvent extends BaseEvent {
this.preData = preData; this.preData = preData;
} }
} }
export class ProjectUserAddedEvent extends BaseEvent {
readonly project: string;
readonly data: any;
constructor(p: { project: string; createdBy: string; data: any }) {
super(PROJECT_USER_ADDED, p.createdBy);
const { project, data } = p;
this.project = project;
this.data = data;
}
}