mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
fix: wip project events
This commit is contained in:
parent
c1826ca79a
commit
cab9f5dffc
@ -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
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user