mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: add group-deleted event (#4816)
Adds a missing `group-deleted` event.
This commit is contained in:
parent
b4742df8be
commit
b6b0f83e3d
@ -11,7 +11,7 @@ import { IUnleashConfig, IUnleashStores } from '../types';
|
||||
import { IGroupStore } from '../types/stores/group-store';
|
||||
import { Logger } from '../logger';
|
||||
import BadDataError from '../error/bad-data-error';
|
||||
import { GROUP_CREATED, GROUP_UPDATED } from '../types/events';
|
||||
import { GROUP_CREATED, GROUP_DELETED, GROUP_UPDATED } from '../types/events';
|
||||
import { IEventStore } from '../types/stores/event-store';
|
||||
import NameExistsError from '../error/name-exists-error';
|
||||
import { IAccountStore } from '../types/stores/account-store';
|
||||
@ -170,8 +170,18 @@ export class GroupService {
|
||||
return [];
|
||||
}
|
||||
|
||||
async deleteGroup(id: number): Promise<void> {
|
||||
return this.groupStore.delete(id);
|
||||
async deleteGroup(id: number, userName?: string): Promise<void> {
|
||||
const group = await this.groupStore.get(id);
|
||||
|
||||
await this.groupStore.delete(id);
|
||||
|
||||
if (userName) {
|
||||
await this.eventStore.store({
|
||||
type: GROUP_DELETED,
|
||||
createdBy: userName,
|
||||
data: group,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async validateGroup(
|
||||
|
@ -90,6 +90,7 @@ export const SEGMENT_UPDATED = 'segment-updated' as const;
|
||||
export const SEGMENT_DELETED = 'segment-deleted' as const;
|
||||
export const GROUP_CREATED = 'group-created' as const;
|
||||
export const GROUP_UPDATED = 'group-updated' as const;
|
||||
export const GROUP_DELETED = 'group-deleted' as const;
|
||||
export const SETTING_CREATED = 'setting-created' as const;
|
||||
export const SETTING_UPDATED = 'setting-updated' as const;
|
||||
export const SETTING_DELETED = 'setting-deleted' as const;
|
||||
@ -213,6 +214,7 @@ export const IEventTypes = [
|
||||
SEGMENT_DELETED,
|
||||
GROUP_CREATED,
|
||||
GROUP_UPDATED,
|
||||
GROUP_DELETED,
|
||||
SETTING_CREATED,
|
||||
SETTING_UPDATED,
|
||||
SETTING_DELETED,
|
||||
|
Loading…
Reference in New Issue
Block a user